package IR;
import java.util.*;
import IR.Tree.*;
-import IR.SymbolTable;
-import IR.FieldDescriptor;
-import IR.MethodDescriptor;
-import IR.NameDescriptor;
public class ClassDescriptor extends Descriptor {
public ClassDescriptor(String classname) {
Modifiers modifiers;
SymbolTable fields;
+ SymbolTable flags;
SymbolTable methods;
public int getId() {
public Iterator getFields() {
return fields.getDescriptorsIterator();
}
+
+ public Iterator getFlags() {
+ return flags.getDescriptorsIterator();
+ }
public SymbolTable getFieldTable() {
return fields;
}
+ public SymbolTable getFlagTable() {
+ return flags;
+ }
+
public SymbolTable getMethodTable() {
return methods;
}
indent=TreeNode.INDENT;
boolean printcr=false;
+ for(Iterator it=getFlags();it.hasNext();) {
+ FlagDescriptor fd=(FlagDescriptor)it.next();
+ st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
+ printcr=true;
+ }
+ if (printcr)
+ st+="\n";
+
+ printcr=false;
+
for(Iterator it=getFields();it.hasNext();) {
FieldDescriptor fd=(FieldDescriptor)it.next();
st+=TreeNode.printSpace(indent)+fd.toString()+"\n";
return st;
}
+ public void addFlag(FlagDescriptor fd) {
+ if (flags.contains(fd.getSymbol()))
+ throw new Error(fd.getSymbol()+" already defined");
+ flags.add(fd);
+ }
+
public void addField(FieldDescriptor fd) {
if (fields.contains(fd.getSymbol()))
throw new Error(fd.getSymbol()+" already defined");
super(identifier);
this.modifier=m;
this.td=t;
- this.identifier=identifier;
this.en=e;
this.safename = "___" + name + "___";
this.uniqueid=count++;
public String toString() {
if (en==null)
- return modifier.toString()+td.toString()+" "+identifier+";";
+ return modifier.toString()+td.toString()+" "+getSymbol()+";";
else
- return modifier.toString()+td.toString()+" "+identifier+"="+en.printNode(0)+";";
+ return modifier.toString()+td.toString()+" "+getSymbol()+"="+en.printNode(0)+";";
}
}
key_table.put("void", new Integer(Sym.VOID));
key_table.put("volatile", new Integer(Sym.VOLATILE));
key_table.put("while", new Integer(Sym.WHILE));
+ //Keywords for failure aware computation
+ key_table.put("flag", new Integer(Sym.FLAG));
+ key_table.put("tag", new Integer(Sym.TAG));
+ key_table.put("task", new Integer(Sym.TASK));
}
}
"native", "new", "package", "private", "protected", "public",
"return", "short", "static", "strictfp", "super", "switch",
"synchronized", "this", "throw", "throws", "transient", "try", "void",
- "volatile", "while" };
+ "volatile", "while",
+ //keywords for failure aware computation
+ "flag", "tag", "task"};
Token getIdentifier() {
// Get id string.
StringBuffer sb = new StringBuffer().append(consume());
terminal ELLIPSIS;
terminal ENUM;
+//failure aware computation keywords
+terminal FLAG;
+terminal TAG;
+terminal TASK;
+non terminal ParseNode flag_declaration;
+
// 19.2) The Syntactic Grammar
non terminal ParseNode goal;
// 19.3) Lexical Structure
:}
;
class_member_declaration ::=
+ //failure aware computation
+ flag_declaration:flag {:
+ RESULT=(new ParseNode("flag")).addChild(flag).getRoot();
+ :}
+ |
field_declaration:field {:
RESULT=(new ParseNode("field")).addChild(field).getRoot();
:}
| SEMICOLON {: RESULT=new ParseNode("empty"); :}
;
+//Failure aware computation
+flag_declaration ::=
+ FLAG IDENTIFIER:id SEMICOLON {:
+ ParseNode pn=new ParseNode("flag_declaration");
+ pn.addChild("name").addChild(id);
+ RESULT=pn;
+ :}
+ ;
+
// 19.8.2) Field Declarations
field_declaration ::=
modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
Objects have:
Collection of Flags
+ Flags have type/name associated with them
+ Are either present or not present
Collection of Tags
+ Tags have type/name associated with them
+ Also have UID associated with them
+ Two basic types:
+ Ordered: Initial/Next / Preserves Sequencing
+ Non-ordered: New / Groups items together
+
----------------------------------------------------------------------
Tasks:
Have list of parameters w/ flag/tag specifications