From 4c5cf0dfec966d6e529c4f25cef9f8c5887ac99a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 20 Apr 2006 20:34:52 +0000 Subject: [PATCH] changes --- Robust/src/IR/State.java | 10 +++ Robust/src/IR/Tree/BuildIR.java | 69 ++++++++++++++----- .../IR/Tree/{FieldNode.java => FlagNode.java} | 0 3 files changed, 62 insertions(+), 17 deletions(-) rename Robust/src/IR/Tree/{FieldNode.java => FlagNode.java} (100%) diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index ee0d12bb..a811df08 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -9,6 +9,7 @@ public class State { public State() { this.classes=new SymbolTable(); + this.tasks=new SymbolTable(); this.treemethodmap=new Hashtable(); this.flatmethodmap=new Hashtable(); this.parsetrees=new HashSet(); @@ -21,12 +22,14 @@ public class State { } public SymbolTable classes; + public SymbolTable tasks; public Set parsetrees; public Hashtable treemethodmap; public Hashtable flatmethodmap; private HashSet arraytypes; public Hashtable arraytonumber; private int numclasses=0; + private int numtasks=0; private int arraycount=0; public void addArrayType(TypeDescriptor td) { @@ -92,4 +95,11 @@ public class State { public void addFlatCode(MethodDescriptor md, FlatMethod bn) { flatmethodmap.put(md,bn); } + + public void addTask(TaskDescriptor td) { + if (tasks.contains(td.getSymbol())) + throw new Error("Task "+td.getSymbol()+" defined twice"); + tasks.add(td); + numtasks++; + } } diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 6a22ef7a..44d793ec 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -24,28 +24,63 @@ public class BuildIR { ParseNode type_pn=pnv.elementAt(i); if (isEmpty(type_pn)) /* Skip the semicolon */ continue; - ClassDescriptor cn=parseTypeDecl(type_pn); - state.addClass(cn); + if (isNode(type_pn,"class_declaration")) { + ClassDescriptor cn=parseTypeDecl(type_pn); + state.addClass(cn); + } else if (isNode(type_pn,"task_declaration")) { + TaskDescriptor td=parseTaskDecl(type_pn); + state.addTask(td); + } throw new Error(); } } } + public TaskDescriptor parseTaskDecl(ParseNode pn) { + TaskDescriptor td=new TaskDescriptor(pn.getChild("name").getTerminal()); + + ParseNode bodyn=pn.getChild("body"); + BlockNode bn=parseBlock(bodyn); + parseParameterList(td, pn); + state.addTreeCode(td,bn); + return td; + } + + + public void parseParameterList(TaskDescriptor td, ParseNode pn) { + ParseNode paramlist=pn.getChild("task_parameter_list"); + if (paramlist==null) + return; + ParseNodeVector pnv=paramlist.getChildren(); + for(int i=0;i