From: bdemsky Date: Thu, 13 Apr 2006 00:40:20 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: preEdgeChange~924 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ed793bc741814dc9d48871830af5cbff99d9f8e6;p=IRC.git *** empty log message *** --- diff --git a/Robust/src/IR/ClassDescriptor.java b/Robust/src/IR/ClassDescriptor.java index aae2e558..504d026d 100644 --- a/Robust/src/IR/ClassDescriptor.java +++ b/Robust/src/IR/ClassDescriptor.java @@ -1,10 +1,6 @@ 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) { @@ -24,6 +20,7 @@ public class ClassDescriptor extends Descriptor { Modifiers modifiers; SymbolTable fields; + SymbolTable flags; SymbolTable methods; public int getId() { @@ -37,11 +34,19 @@ public class ClassDescriptor extends Descriptor { 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; } @@ -59,6 +64,16 @@ public class ClassDescriptor extends Descriptor { 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"; @@ -77,6 +92,12 @@ public class ClassDescriptor extends Descriptor { 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"); diff --git a/Robust/src/IR/FieldDescriptor.java b/Robust/src/IR/FieldDescriptor.java index 41626d41..883147d8 100644 --- a/Robust/src/IR/FieldDescriptor.java +++ b/Robust/src/IR/FieldDescriptor.java @@ -21,7 +21,6 @@ public class FieldDescriptor extends Descriptor { super(identifier); this.modifier=m; this.td=t; - this.identifier=identifier; this.en=e; this.safename = "___" + name + "___"; this.uniqueid=count++; @@ -34,8 +33,8 @@ public class FieldDescriptor extends Descriptor { 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)+";"; } } diff --git a/Robust/src/Lex/Keyword.java b/Robust/src/Lex/Keyword.java index 4fa882ca..9ea982e1 100644 --- a/Robust/src/Lex/Keyword.java +++ b/Robust/src/Lex/Keyword.java @@ -64,5 +64,9 @@ class Keyword extends Token { 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)); } } diff --git a/Robust/src/Lex/Lexer.java b/Robust/src/Lex/Lexer.java index 2fc1a8b5..ad1a10da 100644 --- a/Robust/src/Lex/Lexer.java +++ b/Robust/src/Lex/Lexer.java @@ -251,7 +251,9 @@ public class Lexer { "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()); diff --git a/Robust/src/Parse/java14.cup b/Robust/src/Parse/java14.cup index ec6c5b80..f4883444 100644 --- a/Robust/src/Parse/java14.cup +++ b/Robust/src/Parse/java14.cup @@ -103,6 +103,12 @@ terminal ASSERT; // assert_statement 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 @@ -489,6 +495,11 @@ class_body_declaration ::= :} ; 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(); :} @@ -501,6 +512,15 @@ class_member_declaration ::= | 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 {: diff --git a/Robust/src/designnotes b/Robust/src/designnotes index 72c4ae99..fa036757 100644 --- a/Robust/src/designnotes +++ b/Robust/src/designnotes @@ -1,6 +1,14 @@ 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