6 public class BuildFlat {
9 MethodDescriptor currmd;
16 public BuildFlat(State st, TypeUtil typeutil) {
18 temptovar=new Hashtable();
19 this.typeutil=typeutil;
20 this.breakset=new HashSet();
21 this.continueset=new HashSet();
24 public Hashtable getMap() {
28 public void buildFlat() {
29 Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
31 ClassDescriptor cn=(ClassDescriptor)it.next();
35 Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator();
36 while(task_it.hasNext()) {
37 TaskDescriptor td=(TaskDescriptor)task_it.next();
42 private void flattenTask(TaskDescriptor td) {
43 BlockNode bn=state.getMethodBody(td);
44 NodePair np=flattenBlockNode(bn);
45 FlatNode fn=np.getBegin();
47 FlatNode fn2=np.getEnd();
49 if (fn2!=null&& fn2.kind()!=FKind.FlatReturnNode) {
50 FlatReturnNode rnflat=new FlatReturnNode(null);
55 FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.PRE);
58 FlatMethod fm=new FlatMethod(td, fe);
61 Hashtable visitedset=new Hashtable();
63 for(int i=0; i<td.numParameters(); i++) {
64 VarDescriptor paramvd=td.getParameter(i);
65 fm.addParameterTemp(getTempforVar(paramvd));
66 TagExpressionList tel=td.getTag(paramvd);
67 //BUG added next line to fix...to test feed in any task program
69 for(int j=0; j<tel.numTags(); j++) {
70 TagVarDescriptor tvd=(TagVarDescriptor) td.getParameterTable().getFromSameScope(tel.getName(j));
71 TempDescriptor tagtmp=getTempforVar(tvd);
72 if (!visitedset.containsKey(tvd.getName())) {
73 visitedset.put(tvd.getName(),tvd.getTag());
74 fm.addTagTemp(tagtmp);
76 TagDescriptor tmptd=(TagDescriptor) visitedset.get(tvd.getName());
77 if (!tmptd.equals(tvd.getTag()))
78 throw new Error("Two different tag types with same name as parameters to:"+td);
80 tel.setTemp(j, tagtmp);
84 /* Flatten Vector of Flag Effects */
85 Vector flags=td.getFlagEffects();
86 updateFlagActionNode(ffan,flags);
88 state.addFlatCode(td,fm);
92 /* This method transforms a vector of FlagEffects into the FlatFlagActionNode */
93 private void updateFlagActionNode(FlatFlagActionNode ffan, Vector flags) {
94 if (flags==null) // Do nothing if the flag effects vector is empty
97 for(int i=0; i<flags.size(); i++) {
98 FlagEffects fes=(FlagEffects)flags.get(i);
99 TempDescriptor flagtemp=getTempforVar(fes.getVar());
101 for(int j=0; j<fes.numEffects(); j++) {
102 FlagEffect fe=fes.getEffect(j);
103 ffan.addFlagAction(flagtemp, fe.getFlag(), fe.getStatus());
106 for(int j=0; j<fes.numTagEffects(); j++) {
107 TagEffect te=fes.getTagEffect(j);
108 TempDescriptor tagtemp=getTempforVar(te.getTag());
110 ffan.addTagAction(flagtemp, te.getTag().getTag(), tagtemp, te.getStatus());
115 FlatAtomicEnterNode curran=null;
117 private void flattenClass(ClassDescriptor cn) {
118 Iterator methodit=cn.getMethods();
119 while(methodit.hasNext()) {
120 currmd=(MethodDescriptor)methodit.next();
122 FlatSESEEnterNode mainSESE = null;
123 FlatSESEExitNode mainExit = null;
124 if (state.MLP && currmd.equals(typeutil.getMain())) {
125 SESENode mainTree = new SESENode( "main" );
126 mainSESE = new FlatSESEEnterNode( mainTree );
127 mainExit = new FlatSESEExitNode ( mainTree );
128 mainSESE.setFlatExit ( mainExit );
129 mainExit.setFlatEnter( mainSESE );
134 BlockNode bn=state.getMethodBody(currmd);
136 if (state.DSM&&currmd.getModifiers().isAtomic()) {
137 curran=new FlatAtomicEnterNode();
140 NodePair np=flattenBlockNode(bn);
141 FlatNode fn=np.getBegin();
142 if (state.THREAD&&currmd.getModifiers().isSynchronized()) {
143 MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter");
144 TempDescriptor thistd=getTempforVar(currmd.getThis());
145 FlatCall fc=new FlatCall(memd, null, thistd, new TempDescriptor[0]);
148 if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
149 MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
150 FlatCall fcunlock=new FlatCall(memdex, null, thistd, new TempDescriptor[0]);
151 np.getEnd().addNext(fcunlock);
152 FlatReturnNode rnflat=new FlatReturnNode(null);
153 fcunlock.addNext(rnflat);
156 } else if (state.DSM&&currmd.getModifiers().isAtomic()) {
159 if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
160 FlatAtomicExitNode aen=new FlatAtomicExitNode(curran);
161 np.getEnd().addNext(aen);
162 FlatReturnNode rnflat=new FlatReturnNode(null);
167 } else if (state.MLP && mainSESE != null) {
168 mainSESE.addNext(fn);
170 FlatReturnNode rnflat=new FlatReturnNode(null);
171 np.getEnd().addNext(mainExit);
172 mainExit.addNext(rnflat);
175 } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
176 FlatReturnNode rnflat=new FlatReturnNode(null);
177 np.getEnd().addNext(rnflat);
181 FlatMethod fm=new FlatMethod(currmd, fe);
183 if (!currmd.isStatic())
184 fm.addParameterTemp(getTempforParam(currmd.getThis()));
185 for(int i=0; i<currmd.numParameters(); i++) {
186 fm.addParameterTemp(getTempforParam(currmd.getParameter(i)));
189 state.addFlatCode(currmd,fm);
193 private NodePair flattenBlockNode(BlockNode bn) {
196 for(int i=0; i<bn.size(); i++) {
197 NodePair np=flattenBlockStatementNode(bn.get(i));
198 FlatNode np_begin=np.getBegin();
199 FlatNode np_end=np.getEnd();
206 end.addNext(np_begin);
208 return new NodePair(begin, null);
214 end=begin=new FlatNop();
216 return new NodePair(begin,end);
219 private NodePair flattenBlockExpressionNode(BlockExpressionNode en) {
220 //System.out.println("DEBUG -> inside flattenBlockExpressionNode\n");
221 TempDescriptor tmp=TempDescriptor.tempFactory("neverused",en.getExpression().getType());
222 return flattenExpressionNode(en.getExpression(),tmp);
225 private NodePair flattenCastNode(CastNode cn,TempDescriptor out_temp) {
226 TempDescriptor tmp=TempDescriptor.tempFactory("tocast",cn.getExpression().getType());
227 NodePair np=flattenExpressionNode(cn.getExpression(), tmp);
228 FlatCastNode fcn=new FlatCastNode(cn.getType(), tmp, out_temp);
229 np.getEnd().addNext(fcn);
230 return new NodePair(np.getBegin(),fcn);
233 private NodePair flattenLiteralNode(LiteralNode ln,TempDescriptor out_temp) {
234 FlatLiteralNode fln=new FlatLiteralNode(ln.getType(), ln.getValue(), out_temp);
235 return new NodePair(fln,fln);
238 private NodePair flattenOffsetNode(OffsetNode ofn, TempDescriptor out_temp) {
239 FlatOffsetNode fln = new FlatOffsetNode(ofn.getClassType(), ofn.getField(), out_temp);
240 return new NodePair(fln, fln);
243 private NodePair flattenCreateObjectNode(CreateObjectNode con,TempDescriptor out_temp) {
244 TypeDescriptor td=con.getType();
246 FlatNode fn=new FlatNew(td, out_temp, con.isGlobal(), con.getDisjointId());
248 //handle wrapper fields
249 ClassDescriptor cd=td.getClassDesc();
250 for(Iterator fieldit=cd.getFields();fieldit.hasNext();) {
251 FieldDescriptor fd=(FieldDescriptor)fieldit.next();
252 if (fd.getType().iswrapper()) {
253 TempDescriptor wrap_tmp=TempDescriptor.tempFactory("wrapper_obj",fd.getType());
254 FlatNode fnwrapper=new FlatNew(fd.getType(), wrap_tmp, con.isGlobal());
255 FlatSetFieldNode fsfn=new FlatSetFieldNode(out_temp, fd, wrap_tmp);
256 last.addNext(fnwrapper);
257 fnwrapper.addNext(fsfn);
262 TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
265 for(int i=0; i<con.numArgs(); i++) {
266 ExpressionNode en=con.getArg(i);
267 TempDescriptor tmp=TempDescriptor.tempFactory("arg",en.getType());
269 NodePair np=flattenExpressionNode(en, tmp);
270 last.addNext(np.getBegin());
273 MethodDescriptor md=con.getConstructor();
274 //Call to constructor
275 FlatCall fc=new FlatCall(md, null, out_temp, temps);
278 if (td.getClassDesc().hasFlags()) {
279 // if (con.getFlagEffects()!=null) {
280 FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.NEWOBJECT);
281 FlagEffects fes=con.getFlagEffects();
282 TempDescriptor flagtemp=out_temp;
284 for(int j=0; j<fes.numEffects(); j++) {
285 FlagEffect fe=fes.getEffect(j);
286 ffan.addFlagAction(flagtemp, fe.getFlag(), fe.getStatus());
288 for(int j=0; j<fes.numTagEffects(); j++) {
289 TagEffect te=fes.getTagEffect(j);
290 TempDescriptor tagtemp=getTempforVar(te.getTag());
292 ffan.addTagAction(flagtemp, te.getTag().getTag(), tagtemp, te.getStatus());
295 ffan.addFlagAction(flagtemp, null, false);
300 return new NodePair(fn,last);
304 TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
305 for (int i=0; i<con.numArgs(); i++) {
306 ExpressionNode en=con.getArg(i);
307 TempDescriptor tmp=TempDescriptor.tempFactory("arg",en.getType());
309 NodePair np=flattenExpressionNode(en, tmp);
313 last.addNext(np.getBegin());
316 TempDescriptor tmp2=(i==0) ?
318 TempDescriptor.tempFactory("arg",en.getType());
320 FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal(), con.getDisjointId());
322 if (temps.length>1) {
323 NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
324 fn.addNext(np.getBegin());
325 return new NodePair(first,np.getEnd());
326 } else if (td.isArray()&&td.dereference().iswrapper()) {
327 NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
328 fn.addNext(np.getBegin());
329 return new NodePair(first,np.getEnd());
331 return new NodePair(first, fn);
335 private NodePair generateNewArrayLoop(TempDescriptor[] temparray, TypeDescriptor td, TempDescriptor tmp, int i, boolean isglobal) {
336 TempDescriptor index=TempDescriptor.tempFactory("index",new TypeDescriptor(TypeDescriptor.INT));
337 TempDescriptor tmpone=TempDescriptor.tempFactory("index",new TypeDescriptor(TypeDescriptor.INT));
338 FlatNop fnop=new FlatNop(); //last node
341 FlatLiteralNode fln=new FlatLiteralNode(index.getType(),new Integer(0),index);
343 FlatLiteralNode fln2=new FlatLiteralNode(tmpone.getType(),new Integer(1),tmpone);
345 TempDescriptor tmpbool=TempDescriptor.tempFactory("comp",new TypeDescriptor(TypeDescriptor.BOOLEAN));
347 FlatOpNode fcomp=new FlatOpNode(tmpbool,index,temparray[i],new Operation(Operation.LT));
348 FlatCondBranch fcb=new FlatCondBranch(tmpbool);
349 fcb.setTrueProb(State.TRUEPROB);
352 TempDescriptor new_tmp=TempDescriptor.tempFactory("tmp",td);
353 FlatNew fn=td.iswrapper()?new FlatNew(td, new_tmp, isglobal):new FlatNew(td, new_tmp, temparray[i+1], isglobal);
354 FlatSetElementNode fsen=new FlatSetElementNode(tmp,index,new_tmp);
356 FlatOpNode fon=new FlatOpNode(index,index,tmpone,new Operation(Operation.ADD));
362 fcb.addFalseNext(fnop);
364 //Recursive call here
365 if ((i+2)<temparray.length) {
366 NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1, isglobal);
367 fsen.addNext(np2.getBegin());
368 np2.getEnd().addNext(fon);
369 } else if (td.isArray()&&td.dereference().iswrapper()) {
370 NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1, isglobal);
371 fsen.addNext(np2.getBegin());
372 np2.getEnd().addNext(fon);
377 return new NodePair(fln, fnop);
380 private NodePair flattenMethodInvokeNode(MethodInvokeNode min,TempDescriptor out_temp) {
381 TempDescriptor[] temps=new TempDescriptor[min.numArgs()];
384 TempDescriptor thisarg=null;
386 if (min.getExpression()!=null) {
387 thisarg=TempDescriptor.tempFactory("thisarg",min.getExpression().getType());
388 NodePair np=flattenExpressionNode(min.getExpression(),thisarg);
394 for(int i=0; i<min.numArgs(); i++) {
395 ExpressionNode en=min.getArg(i);
396 TempDescriptor td=TempDescriptor.tempFactory("arg",en.getType());
398 NodePair np=flattenExpressionNode(en, td);
402 last.addNext(np.getBegin());
406 MethodDescriptor md=min.getMethod();
408 //Call to constructor
411 if(md.getReturnType()==null||md.getReturnType().isVoid())
412 fc=new FlatCall(md, null, thisarg, temps);
414 fc=new FlatCall(md, out_temp, thisarg, temps);
419 return new NodePair(first,fc);
422 private NodePair flattenFieldAccessNode(FieldAccessNode fan,TempDescriptor out_temp) {
423 TempDescriptor tmp=TempDescriptor.tempFactory("temp",fan.getExpression().getType());
424 NodePair npe=flattenExpressionNode(fan.getExpression(),tmp);
425 FlatFieldNode fn=new FlatFieldNode(fan.getField(),tmp,out_temp);
426 npe.getEnd().addNext(fn);
427 return new NodePair(npe.getBegin(),fn);
430 private NodePair flattenArrayAccessNode(ArrayAccessNode aan,TempDescriptor out_temp) {
431 TempDescriptor tmp=TempDescriptor.tempFactory("temp",aan.getExpression().getType());
432 TempDescriptor tmpindex=TempDescriptor.tempFactory("temp",aan.getIndex().getType());
433 NodePair npe=flattenExpressionNode(aan.getExpression(),tmp);
434 NodePair npi=flattenExpressionNode(aan.getIndex(),tmpindex);
435 TempDescriptor arraytmp=out_temp;
436 if (aan.iswrapper()) {
438 arraytmp=TempDescriptor.tempFactory("temp", aan.getExpression().getType().dereference());
440 FlatNode fn=new FlatElementNode(tmp,tmpindex,arraytmp);
441 npe.getEnd().addNext(npi.getBegin());
442 npi.getEnd().addNext(fn);
443 if (aan.iswrapper()) {
444 FlatFieldNode ffn=new FlatFieldNode((FieldDescriptor)aan.getExpression().getType().dereference().getClassDesc().getFieldTable().get("value") ,arraytmp,out_temp);
448 return new NodePair(npe.getBegin(),fn);
451 private NodePair flattenAssignmentNode(AssignmentNode an,TempDescriptor out_temp) {
453 // left side is variable
454 // left side is field
455 // left side is array
457 Operation base=an.getOperation().getBaseOp();
458 boolean pre=base==null||(base.getOp()!=Operation.POSTINC&&base.getOp()!=Operation.POSTDEC);
461 //rewrite the base operation
462 base=base.getOp()==Operation.POSTINC ? new Operation(Operation.ADD) : new Operation(Operation.SUB);
466 TempDescriptor src_tmp = src_tmp=an.getSrc()==null ? TempDescriptor.tempFactory("srctmp",an.getDest().getType()) : TempDescriptor.tempFactory("srctmp",an.getSrc().getType());
469 if (an.getSrc()!=null) {
470 NodePair np_src=flattenExpressionNode(an.getSrc(),src_tmp);
471 first=np_src.getBegin();
472 last=np_src.getEnd();
474 FlatLiteralNode fln=new FlatLiteralNode(new TypeDescriptor(TypeDescriptor.INT),new Integer(1),src_tmp);
479 if (an.getDest().kind()==Kind.FieldAccessNode) {
480 //We are assigning an object field
482 FieldAccessNode fan=(FieldAccessNode)an.getDest();
483 ExpressionNode en=fan.getExpression();
484 TempDescriptor dst_tmp=TempDescriptor.tempFactory("dst",en.getType());
485 NodePair np_baseexp=flattenExpressionNode(en, dst_tmp);
487 first=np_baseexp.getBegin();
489 last.addNext(np_baseexp.getBegin());
490 last=np_baseexp.getEnd();
492 //See if we need to perform an operation
494 //If it is a preinc we need to store the initial value
495 TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
496 TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
497 FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
501 if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
502 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
503 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
504 FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
509 FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
516 FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
520 FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
524 return new NodePair(first, last);
525 } else if (an.getDest().kind()==Kind.ArrayAccessNode) {
526 //We are assigning an array element
528 ArrayAccessNode aan=(ArrayAccessNode)an.getDest();
529 ExpressionNode en=aan.getExpression();
530 ExpressionNode enindex=aan.getIndex();
531 TempDescriptor dst_tmp=TempDescriptor.tempFactory("dst",en.getType());
532 TempDescriptor index_tmp=TempDescriptor.tempFactory("index",enindex.getType());
533 NodePair np_baseexp=flattenExpressionNode(en, dst_tmp);
534 NodePair np_indexexp=flattenExpressionNode(enindex, index_tmp);
536 first=np_baseexp.getBegin();
538 last.addNext(np_baseexp.getBegin());
539 np_baseexp.getEnd().addNext(np_indexexp.getBegin());
540 last=np_indexexp.getEnd();
542 //See if we need to perform an operation
544 //If it is a preinc we need to store the initial value
545 TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
546 TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
548 if (aan.iswrapper()) {
549 TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
550 TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
551 FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
552 FlatFieldNode ffn=new FlatFieldNode((FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp3,src_tmp2);
557 FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp2);
561 if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
562 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
563 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
564 FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
569 FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
576 if (aan.iswrapper()) {
577 TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
578 TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
579 FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
580 FlatSetFieldNode fsfn=new FlatSetFieldNode(src_tmp3,(FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp);
585 FlatSetElementNode fsen=new FlatSetElementNode(dst_tmp, index_tmp, src_tmp);
590 FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
594 return new NodePair(first, last);
595 } else if (an.getDest().kind()==Kind.NameNode) {
596 //We could be assigning a field or variable
597 NameNode nn=(NameNode)an.getDest();
600 if (nn.getExpression()!=null) {
602 FieldAccessNode fan=(FieldAccessNode)nn.getExpression();
603 ExpressionNode en=fan.getExpression();
604 TempDescriptor dst_tmp=TempDescriptor.tempFactory("dst",en.getType());
605 NodePair np_baseexp=flattenExpressionNode(en, dst_tmp);
607 first=np_baseexp.getBegin();
609 last.addNext(np_baseexp.getBegin());
610 last=np_baseexp.getEnd();
612 //See if we need to perform an operation
614 //If it is a preinc we need to store the initial value
615 TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
616 TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
618 FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
623 if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
624 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
625 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
626 FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
631 FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
639 FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
643 FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
647 return new NodePair(first, last);
649 if (nn.getField()!=null) {
653 //See if we need to perform an operation
655 //If it is a preinc we need to store the initial value
656 TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
657 TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
659 FlatFieldNode ffn=new FlatFieldNode(nn.getField(), getTempforVar(nn.getVar()), src_tmp2);
668 if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
669 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
670 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
671 FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
676 FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
683 FlatSetFieldNode fsfn=new FlatSetFieldNode(getTempforVar(nn.getVar()), nn.getField(), src_tmp);
691 FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
695 return new NodePair(first, last);
698 //See if we need to perform an operation
701 //If it is a preinc we need to store the initial value
702 TempDescriptor src_tmp2=getTempforVar(nn.getVar());
703 TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
705 FlatOpNode fon=new FlatOpNode(out_temp, src_tmp2, null, new Operation(Operation.ASSIGN));
714 if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
715 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
716 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
717 FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
725 FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
735 FlatOpNode fon=new FlatOpNode(getTempforVar(nn.getVar()), src_tmp, null, new Operation(Operation.ASSIGN));
740 FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
744 return new NodePair(first, last);
752 private NodePair flattenNameNode(NameNode nn,TempDescriptor out_temp) {
753 if (nn.getExpression()!=null) {
754 /* Hack - use subtree instead */
755 return flattenExpressionNode(nn.getExpression(),out_temp);
756 } else if (nn.getField()!=null) {
757 TempDescriptor tmp=getTempforVar(nn.getVar());
758 FlatFieldNode ffn=new FlatFieldNode(nn.getField(), tmp, out_temp);
759 return new NodePair(ffn,ffn);
761 TempDescriptor tmp=getTempforVar(nn.isTag() ? nn.getTagVar() : nn.getVar());
764 out_temp.setTag(tmp.getTag());
766 FlatOpNode fon=new FlatOpNode(out_temp, tmp, null, new Operation(Operation.ASSIGN));
767 return new NodePair(fon,fon);
771 private NodePair flattenOpNode(OpNode on,TempDescriptor out_temp) {
772 TempDescriptor temp_left=TempDescriptor.tempFactory("leftop",on.getLeft().getType());
773 TempDescriptor temp_right=null;
775 Operation op=on.getOp();
777 NodePair left=flattenExpressionNode(on.getLeft(),temp_left);
779 if (on.getRight()!=null) {
780 temp_right=TempDescriptor.tempFactory("rightop",on.getRight().getType());
781 right=flattenExpressionNode(on.getRight(),temp_right);
783 FlatNop nop=new FlatNop();
784 right=new NodePair(nop,nop);
787 if (op.getOp()==Operation.LOGIC_OR) {
788 /* Need to do shortcircuiting */
789 FlatCondBranch fcb=new FlatCondBranch(temp_left);
790 FlatOpNode fon1=new FlatOpNode(out_temp,temp_left,null,new Operation(Operation.ASSIGN));
791 FlatOpNode fon2=new FlatOpNode(out_temp,temp_right,null,new Operation(Operation.ASSIGN));
792 FlatNop fnop=new FlatNop();
793 left.getEnd().addNext(fcb);
794 fcb.addFalseNext(right.getBegin());
795 right.getEnd().addNext(fon2);
797 fcb.addTrueNext(fon1);
799 return new NodePair(left.getBegin(), fnop);
800 } else if (op.getOp()==Operation.LOGIC_AND) {
801 /* Need to do shortcircuiting */
802 FlatCondBranch fcb=new FlatCondBranch(temp_left);
803 FlatOpNode fon1=new FlatOpNode(out_temp,temp_left,null,new Operation(Operation.ASSIGN));
804 FlatOpNode fon2=new FlatOpNode(out_temp,temp_right,null,new Operation(Operation.ASSIGN));
805 FlatNop fnop=new FlatNop();
806 left.getEnd().addNext(fcb);
807 fcb.addTrueNext(right.getBegin());
808 right.getEnd().addNext(fon2);
810 fcb.addFalseNext(fon1);
812 return new NodePair(left.getBegin(), fnop);
813 } else if (op.getOp()==Operation.ADD&&on.getLeft().getType().isString()) {
814 //We have a string concatenate
815 ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
816 MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat", new TypeDescriptor[] {new TypeDescriptor(stringcd)});
817 FlatCall fc=new FlatCall(concatmd, out_temp, temp_left, new TempDescriptor[] {temp_right});
818 left.getEnd().addNext(right.getBegin());
819 right.getEnd().addNext(fc);
820 return new NodePair(left.getBegin(), fc);
823 FlatOpNode fon=new FlatOpNode(out_temp,temp_left,temp_right,op);
824 left.getEnd().addNext(right.getBegin());
825 right.getEnd().addNext(fon);
826 return new NodePair(left.getBegin(),fon);
829 private NodePair flattenExpressionNode(ExpressionNode en, TempDescriptor out_temp) {
831 case Kind.AssignmentNode:
832 return flattenAssignmentNode((AssignmentNode)en,out_temp);
835 return flattenCastNode((CastNode)en,out_temp);
837 case Kind.CreateObjectNode:
838 return flattenCreateObjectNode((CreateObjectNode)en,out_temp);
840 case Kind.FieldAccessNode:
841 return flattenFieldAccessNode((FieldAccessNode)en,out_temp);
843 case Kind.ArrayAccessNode:
844 return flattenArrayAccessNode((ArrayAccessNode)en,out_temp);
846 case Kind.LiteralNode:
847 return flattenLiteralNode((LiteralNode)en,out_temp);
849 case Kind.MethodInvokeNode:
850 return flattenMethodInvokeNode((MethodInvokeNode)en,out_temp);
853 return flattenNameNode((NameNode)en,out_temp);
856 return flattenOpNode((OpNode)en,out_temp);
858 case Kind.OffsetNode:
859 return flattenOffsetNode((OffsetNode)en,out_temp);
861 case Kind.TertiaryNode:
862 return flattenTertiaryNode((TertiaryNode)en,out_temp);
864 case Kind.InstanceOfNode:
865 return flattenInstanceOfNode((InstanceOfNode)en,out_temp);
867 case Kind.ArrayInitializerNode:
868 return flattenArrayInitializerNode((ArrayInitializerNode)en,out_temp);
873 private NodePair flattenDeclarationNode(DeclarationNode dn) {
874 VarDescriptor vd=dn.getVarDescriptor();
875 TempDescriptor td=getTempforVar(vd);
876 if (dn.getExpression()!=null)
877 return flattenExpressionNode(dn.getExpression(),td);
879 FlatNop fn=new FlatNop();
880 return new NodePair(fn,fn);
884 private NodePair flattenTagDeclarationNode(TagDeclarationNode dn) {
885 TagVarDescriptor tvd=dn.getTagVarDescriptor();
886 TagDescriptor tag=tvd.getTag();
887 TempDescriptor tmp=getTempforVar(tvd);
888 FlatTagDeclaration ftd=new FlatTagDeclaration(tag, tmp);
889 return new NodePair(ftd,ftd);
892 private TempDescriptor getTempforParam(Descriptor d) {
893 if (temptovar.containsKey(d))
894 return (TempDescriptor)temptovar.get(d);
896 if (d instanceof VarDescriptor) {
897 VarDescriptor vd=(VarDescriptor)d;
898 TempDescriptor td=TempDescriptor.paramtempFactory(vd.getName(),vd.getType());
899 temptovar.put(vd,td);
901 } else if (d instanceof TagVarDescriptor) {
902 TagVarDescriptor tvd=(TagVarDescriptor)d;
903 TypeDescriptor tagtype=new TypeDescriptor(typeutil.getClass(TypeUtil.TagClass));
904 TempDescriptor td=TempDescriptor.paramtempFactory(tvd.getName(), tagtype, tvd.getTag());
905 temptovar.put(tvd,td);
907 } else throw new Error("Unreconized Descriptor");
911 private TempDescriptor getTempforVar(Descriptor d) {
912 if (temptovar.containsKey(d))
913 return (TempDescriptor)temptovar.get(d);
915 if (d instanceof VarDescriptor) {
916 VarDescriptor vd=(VarDescriptor)d;
917 TempDescriptor td=TempDescriptor.tempFactory(vd.getName(), vd.getType());
918 temptovar.put(vd,td);
920 } else if (d instanceof TagVarDescriptor) {
921 TagVarDescriptor tvd=(TagVarDescriptor)d;
922 //BUGFIX TAGTYPE - add next line, modify following
923 //line to tag this new type descriptor, modify
924 //TempDescriptor constructor & factory to set type
925 //using this Type To test, use any program with tags
926 TypeDescriptor tagtype=new TypeDescriptor(typeutil.getClass(TypeUtil.TagClass));
927 TempDescriptor td=TempDescriptor.tempFactory(tvd.getName(),tagtype, tvd.getTag());
928 temptovar.put(tvd,td);
930 } else throw new Error("Unrecognized Descriptor");
934 private NodePair flattenIfStatementNode(IfStatementNode isn) {
935 TempDescriptor cond_temp=TempDescriptor.tempFactory("condition",new TypeDescriptor(TypeDescriptor.BOOLEAN));
936 NodePair cond=flattenExpressionNode(isn.getCondition(),cond_temp);
937 FlatCondBranch fcb=new FlatCondBranch(cond_temp);
938 NodePair true_np=flattenBlockNode(isn.getTrueBlock());
940 FlatNop nopend=new FlatNop();
942 if (isn.getFalseBlock()!=null)
943 false_np=flattenBlockNode(isn.getFalseBlock());
945 FlatNop nop=new FlatNop();
946 false_np=new NodePair(nop,nop);
949 cond.getEnd().addNext(fcb);
950 fcb.addTrueNext(true_np.getBegin());
951 fcb.addFalseNext(false_np.getBegin());
952 if (true_np.getEnd()!=null)
953 true_np.getEnd().addNext(nopend);
954 if (false_np.getEnd()!=null)
955 false_np.getEnd().addNext(nopend);
956 if (nopend.numPrev()==0)
957 return new NodePair(cond.getBegin(), null);
959 return new NodePair(cond.getBegin(), nopend);
962 private NodePair flattenLoopNode(LoopNode ln) {
963 HashSet oldbs=breakset;
964 HashSet oldcs=continueset;
965 breakset=new HashSet();
966 continueset=new HashSet();
968 if (ln.getType()==LoopNode.FORLOOP) {
969 NodePair initializer=flattenBlockNode(ln.getInitializer());
970 TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
971 NodePair condition=flattenExpressionNode(ln.getCondition(),cond_temp);
972 NodePair update=flattenBlockNode(ln.getUpdate());
973 NodePair body=flattenBlockNode(ln.getBody());
974 FlatNode begin=initializer.getBegin();
975 FlatCondBranch fcb=new FlatCondBranch(cond_temp);
976 fcb.setTrueProb(State.TRUEPROB);
978 FlatNop nopend=new FlatNop();
979 FlatBackEdge backedge=new FlatBackEdge();
981 FlatNop nop2=new FlatNop();
982 initializer.getEnd().addNext(nop2);
983 nop2.addNext(condition.getBegin());
984 if (body.getEnd()!=null)
985 body.getEnd().addNext(update.getBegin());
986 update.getEnd().addNext(backedge);
987 backedge.addNext(condition.getBegin());
988 condition.getEnd().addNext(fcb);
989 fcb.addFalseNext(nopend);
990 fcb.addTrueNext(body.getBegin());
991 for(Iterator contit=continueset.iterator();contit.hasNext();) {
992 FlatNode fn=(FlatNode)contit.next();
994 fn.addNext(update.getBegin());
996 for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
997 FlatNode fn=(FlatNode)breakit.next();
1003 return new NodePair(begin,nopend);
1004 } else if (ln.getType()==LoopNode.WHILELOOP) {
1005 TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
1006 NodePair condition=flattenExpressionNode(ln.getCondition(),cond_temp);
1007 NodePair body=flattenBlockNode(ln.getBody());
1008 FlatNode begin=condition.getBegin();
1009 FlatCondBranch fcb=new FlatCondBranch(cond_temp);
1010 fcb.setTrueProb(State.TRUEPROB);
1012 FlatNop nopend=new FlatNop();
1013 FlatBackEdge backedge=new FlatBackEdge();
1015 if (body.getEnd()!=null)
1016 body.getEnd().addNext(backedge);
1017 backedge.addNext(condition.getBegin());
1019 condition.getEnd().addNext(fcb);
1020 fcb.addFalseNext(nopend);
1021 fcb.addTrueNext(body.getBegin());
1023 for(Iterator contit=continueset.iterator();contit.hasNext();) {
1024 FlatNode fn=(FlatNode)contit.next();
1026 fn.addNext(backedge);
1028 for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
1029 FlatNode fn=(FlatNode)breakit.next();
1035 return new NodePair(begin,nopend);
1036 } else if (ln.getType()==LoopNode.DOWHILELOOP) {
1037 TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
1038 NodePair condition=flattenExpressionNode(ln.getCondition(),cond_temp);
1039 NodePair body=flattenBlockNode(ln.getBody());
1040 FlatNode begin=body.getBegin();
1041 FlatCondBranch fcb=new FlatCondBranch(cond_temp);
1042 fcb.setTrueProb(State.TRUEPROB);
1044 FlatNop nopend=new FlatNop();
1045 FlatBackEdge backedge=new FlatBackEdge();
1047 if (body.getEnd()!=null)
1048 body.getEnd().addNext(condition.getBegin());
1049 condition.getEnd().addNext(fcb);
1050 fcb.addFalseNext(nopend);
1051 fcb.addTrueNext(backedge);
1052 backedge.addNext(body.getBegin());
1054 for(Iterator contit=continueset.iterator();contit.hasNext();) {
1055 FlatNode fn=(FlatNode)contit.next();
1057 fn.addNext(condition.getBegin());
1059 for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
1060 FlatNode fn=(FlatNode)breakit.next();
1066 return new NodePair(begin,nopend);
1067 } else throw new Error();
1070 private NodePair flattenReturnNode(ReturnNode rntree) {
1071 TempDescriptor retval=null;
1073 if (rntree.getReturnExpression()!=null) {
1074 retval=TempDescriptor.tempFactory("ret_value", rntree.getReturnExpression().getType());
1075 cond=flattenExpressionNode(rntree.getReturnExpression(),retval);
1078 FlatReturnNode rnflat=new FlatReturnNode(retval);
1081 if (state.THREAD&&currmd.getModifiers().isSynchronized()) {
1082 MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
1083 TempDescriptor thistd=getTempforVar(currmd.getThis());
1084 FlatCall fc=new FlatCall(memd, null, thistd, new TempDescriptor[0]);
1088 if (state.DSM&&currmd.getModifiers().isAtomic()) {
1089 FlatAtomicExitNode faen=new FlatAtomicExitNode(curran);
1095 cond.getEnd().addNext(ln);
1096 return new NodePair(cond.getBegin(),null);
1098 return new NodePair(ln,null);
1101 private NodePair flattenTaskExitNode(TaskExitNode ten) {
1102 FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.TASKEXIT);
1103 ffan.setTaskExitIndex(ten.getTaskExitIndex());
1104 updateFlagActionNode(ffan, ten.getFlagEffects());
1105 NodePair fcn=flattenConstraintCheck(ten.getChecks());
1106 ffan.addNext(fcn.getBegin());
1107 FlatReturnNode rnflat=new FlatReturnNode(null);
1109 fcn.getEnd().addNext(rnflat);
1110 return new NodePair(ffan, null);
1113 private NodePair flattenConstraintCheck(Vector ccs) {
1114 FlatNode begin=new FlatNop();
1116 return new NodePair(begin,begin);
1117 FlatNode last=begin;
1118 for(int i=0; i<ccs.size(); i++) {
1119 ConstraintCheck cc=(ConstraintCheck) ccs.get(i);
1120 /* Flatten the arguments */
1121 TempDescriptor[] temps=new TempDescriptor[cc.numArgs()];
1122 String[] vars=new String[cc.numArgs()];
1123 for(int j=0; j<cc.numArgs(); j++) {
1124 ExpressionNode en=cc.getArg(j);
1125 TempDescriptor td=TempDescriptor.tempFactory("arg",en.getType());
1127 vars[j]=cc.getVar(j);
1128 NodePair np=flattenExpressionNode(en, td);
1129 last.addNext(np.getBegin());
1133 FlatCheckNode fcn=new FlatCheckNode(cc.getSpec(), vars, temps);
1137 return new NodePair(begin,last);
1140 private NodePair flattenSubBlockNode(SubBlockNode sbn) {
1141 return flattenBlockNode(sbn.getBlockNode());
1144 private NodePair flattenSynchronizedNode(SynchronizedNode sbn) {
1145 TempDescriptor montmp=TempDescriptor.tempFactory("monitor",sbn.getExpr().getType());
1146 NodePair npexp=flattenExpressionNode(sbn.getExpr(), montmp);
1147 NodePair npblock=flattenBlockNode(sbn.getBlockNode());
1149 MethodDescriptor menmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter");
1150 FlatCall fcen=new FlatCall(menmd, null, montmp, new TempDescriptor[0]);
1152 MethodDescriptor mexmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
1153 FlatCall fcex=new FlatCall(mexmd, null, montmp, new TempDescriptor[0]);
1155 npexp.getEnd().addNext(fcen);
1156 fcen.addNext(npblock.getBegin());
1157 npblock.getEnd().addNext(fcex);
1158 return new NodePair(npexp.getBegin(), fcex);
1161 private NodePair flattenAtomicNode(AtomicNode sbn) {
1162 NodePair np=flattenBlockNode(sbn.getBlockNode());
1163 FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
1164 FlatAtomicExitNode faexn=new FlatAtomicExitNode(faen);
1165 faen.addNext(np.getBegin());
1166 np.getEnd().addNext(faexn);
1167 return new NodePair(faen, faexn);
1170 private NodePair flattenSESENode(SESENode sn) {
1171 if( sn.isStart() ) {
1172 FlatSESEEnterNode fsen=new FlatSESEEnterNode(sn);
1173 sn.setFlatEnter(fsen);
1174 return new NodePair(fsen, fsen);
1177 FlatSESEExitNode fsexn=new FlatSESEExitNode(sn);
1178 sn.setFlatExit(fsexn);
1179 FlatSESEEnterNode fsen=sn.getStart().getFlatEnter();
1180 fsexn.setFlatEnter(fsen);
1181 sn.getStart().getFlatEnter().setFlatExit( fsexn );
1183 return new NodePair(fsexn, fsexn);
1186 private NodePair flattenContinueBreakNode(ContinueBreakNode cbn) {
1187 FlatNop fn=new FlatNop();
1191 continueset.add(fn);
1192 return new NodePair(fn,null);
1195 private NodePair flattenInstanceOfNode(InstanceOfNode tn, TempDescriptor out_temp) {
1196 TempDescriptor expr_temp=TempDescriptor.tempFactory("expr",tn.getExpr().getType());
1197 NodePair cond=flattenExpressionNode(tn.getExpr(), expr_temp);
1198 FlatInstanceOfNode fion=new FlatInstanceOfNode(tn.getExprType(), expr_temp, out_temp);
1199 cond.getEnd().addNext(fion);
1200 return new NodePair(cond.getBegin(),fion);
1203 private NodePair flattenArrayInitializerNode(ArrayInitializerNode ain, TempDescriptor out_temp) {
1205 TempDescriptor expr_temp=TempDescriptor.tempFactory("arry_init",ain.getType());
1207 // create a new array of size equal to the array initializer
1208 //FlatNode first=null;
1209 //FlatNode last=null;
1210 TempDescriptor[] temps=new TempDescriptor[ain.numVarInitializers()];
1212 for (int i=0; i<con.numArgs(); i++) {
1213 ExpressionNode en=con.getArg(i);
1214 TempDescriptor tmp=TempDescriptor.tempFactory("arg",en.getType());
1216 NodePair np=flattenExpressionNode(en, tmp);
1218 first=np.getBegin();
1220 last.addNext(np.getBegin());
1223 TempDescriptor tmp2=(i==0) ?
1225 TempDescriptor.tempFactory("arg",en.getType());
1227 FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal(), con.getDisjointId());
1231 // assign each element of the new array to the flattened expression
1234 FlatOpNode fonAssignArray=new FlatOpNode(out_temp, newarry_temp, null, new Operation(Operation.ASSIGN));
1236 //return new NodePair( , fonAssignArray );
1238 System.out.println( "Array initializers not implemented yet." );
1243 private NodePair flattenTertiaryNode(TertiaryNode tn, TempDescriptor out_temp) {
1244 TempDescriptor cond_temp=TempDescriptor.tempFactory("tert_cond",new TypeDescriptor(TypeDescriptor.BOOLEAN));
1245 TempDescriptor true_temp=TempDescriptor.tempFactory("tert_true",tn.getTrueExpr().getType());
1246 TempDescriptor fals_temp=TempDescriptor.tempFactory("tert_fals",tn.getFalseExpr().getType());
1248 NodePair cond=flattenExpressionNode(tn.getCond(),cond_temp);
1249 FlatCondBranch fcb=new FlatCondBranch(cond_temp);
1251 NodePair trueExpr=flattenExpressionNode(tn.getTrueExpr(),true_temp);
1252 FlatOpNode fonT=new FlatOpNode(out_temp, true_temp, null, new Operation(Operation.ASSIGN));
1254 NodePair falseExpr=flattenExpressionNode(tn.getFalseExpr(),fals_temp);
1255 FlatOpNode fonF=new FlatOpNode(out_temp, fals_temp, null, new Operation(Operation.ASSIGN));
1257 FlatNop nopend=new FlatNop();
1259 cond.getEnd().addNext(fcb);
1261 fcb.addTrueNext(trueExpr.getBegin());
1262 fcb.addFalseNext(falseExpr.getBegin());
1264 trueExpr.getEnd().addNext(fonT);
1265 fonT.addNext(nopend);
1267 falseExpr.getEnd().addNext(fonF);
1268 fonF.addNext(nopend);
1270 return new NodePair(cond.getBegin(), nopend);
1273 private NodePair flattenBlockStatementNode(BlockStatementNode bsn) {
1274 switch(bsn.kind()) {
1275 case Kind.BlockExpressionNode:
1276 return flattenBlockExpressionNode((BlockExpressionNode)bsn);
1278 case Kind.DeclarationNode:
1279 return flattenDeclarationNode((DeclarationNode)bsn);
1281 case Kind.TagDeclarationNode:
1282 return flattenTagDeclarationNode((TagDeclarationNode)bsn);
1284 case Kind.IfStatementNode:
1285 return flattenIfStatementNode((IfStatementNode)bsn);
1288 return flattenLoopNode((LoopNode)bsn);
1290 case Kind.ReturnNode:
1291 return flattenReturnNode((IR.Tree.ReturnNode)bsn);
1293 case Kind.TaskExitNode:
1294 return flattenTaskExitNode((IR.Tree.TaskExitNode)bsn);
1296 case Kind.SubBlockNode:
1297 return flattenSubBlockNode((SubBlockNode)bsn);
1299 case Kind.AtomicNode:
1300 return flattenAtomicNode((AtomicNode)bsn);
1302 case Kind.SynchronizedNode:
1303 return flattenSynchronizedNode((SynchronizedNode)bsn);
1306 return flattenSESENode((SESENode)bsn);
1308 case Kind.ContinueBreakNode:
1309 return flattenContinueBreakNode((ContinueBreakNode)bsn);