/* This method transforms a vector of FlagEffects into the FlatFlagActionNode */
private void updateFlagActionNode(FlatFlagActionNode ffan, Vector flags) {
+ if (flags==null) // Do nothing if the flag effects vector is empty
+ return;
+
for(int i=0;i<flags.size();i++) {
FlagEffects fes=(FlagEffects)flags.get(i);
TempDescriptor flagtemp=getTempforVar(fes.getVar());
parsetrees.add(parsetree);
}
+ /** Boolean flag which indicates whether compiler is compiling a task-based
+ * program. */
+ public boolean TASK;
+
public SymbolTable classes;
public SymbolTable tasks;
public Set parsetrees;
ParseNode flagnode=pn.getChild("flag");
if (flagnode!=null) {
parseFlagDecl(cn, flagnode.getChild("flag_declaration"));
+ return;
}
throw new Error();
}
ParseNode bodyn0=pn.getChild("body");
ParseNode bodyn=bodyn0.getChild("constructor_body");
cn.addMethod(md);
- if (bodyn!=null) {
- BlockNode bn=parseBlock(bodyn);
- state.addTreeCode(md,bn);
- }
+ BlockNode bn=parseBlock(bodyn);
+ state.addTreeCode(md,bn);
}
public BlockNode parseBlock(ParseNode pn) {
- if (isEmpty(pn.getTerminal()))
+ if (pn==null||isEmpty(pn.getTerminal()))
return new BlockNode();
ParseNode bsn=pn.getChild("block_statement_list");
return parseBlockHelper(bsn);
}
public void checkFlagEffects(TaskDescriptor td, Vector vfe) {
+ if (vfe==null)
+ return; /* No flag effects to check */
for(int i=0;i<vfe.size();i++) {
FlagEffects fe=(FlagEffects) vfe.get(i);
String varname=fe.getName();
public int hashCode() {
int hashcode=type^arraycount;
if (type==CLASS)
- hashcode^=class_desc.hashCode();
+ hashcode^=getSymbol().hashCode();
return hashcode;
}
import IR.TypeUtil;
public class Main {
+
public static void main(String args[]) throws Exception {
String ClassLibraryPrefix="./ClassLibrary/";
State state=new State();
ClassLibraryPrefix=args[++i]+"/";
else if (option.equals("-mainclass"))
state.main=args[++i];
+ else if (option.equals("-task"))
+ state.TASK=true;
else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-dir outputdirectory -- output code in outputdirectory");
readSourceFile(state, ClassLibraryPrefix+"Object.java");
readSourceFile(state, ClassLibraryPrefix+"System.java");
readSourceFile(state, ClassLibraryPrefix+"String.java");
+ if (state.TASK)
+ readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
BuildIR bir=new BuildIR(state);
bir.buildtree();
class Example {
flag needoperation;
flag needprinting;
-
+ public Example() {}
+
+
int operation;
int x;
int y;
task DoPrint(Example e{needprinting}) {
System.printInt(e.z);
- taskexit(e {!needprinting};
+ taskexit(e {!needprinting});
}