public override void DefaultIn(Node node) { if (node is PExp) { PExp exp = (PExp) node; if (finalTrans.data.ExpTypes[exp] is ANamedType) { ANamedType type = (ANamedType) finalTrans.data.ExpTypes[exp]; if (finalTrans.data.StructTypeLinks.ContainsKey(type)) { AStructDecl strDecl = finalTrans.data.StructTypeLinks[type]; if (strDecl.GetLocals().Cast<PLocalDecl>().Select(decl => decl is AALocalDecl).Count() == 0) { if (node.Parent() is AAssignmentExp) node = node.Parent().Parent(); MoveMethodDeclsOut mover = new MoveMethodDeclsOut("removedStructVar", finalTrans.data); node.Apply(mover); foreach (PStm pStm in mover.NewStatements) { pStm.Apply(this); } node.Parent().RemoveChild(node); if (node.Parent() is ABinopExp) { ABinopExp parent = (ABinopExp) node.Parent(); ABooleanConstExp replacer; if (parent.GetBinop() is ANeBinop || parent.GetBinop() is AGtBinop || parent.GetBinop() is ALtBinop) replacer = new ABooleanConstExp(new AFalseBool()); else replacer = new ABooleanConstExp(new ATrueBool()); finalTrans.data.ExpTypes[replacer] = new ANamedType(new TIdentifier("bool"), null); parent.ReplaceBy(replacer); } } } } } }
public Parser(Node start) { start.Apply(this); }
public static void Parse(Node ast) { ast.Apply(new SimpleTransformations()); }
public Parser(Node structDecl) { structDecl.Apply(this); }
public static List<AALocalDecl> Parse(Node node, SharedData data) { GetUsedLocals getter = new GetUsedLocals(data); node.Apply(getter); return getter.UsedLocals; }
public Parser(Node ast) { ast.Apply(this); }
public static bool IsWhileNeeded(Node root) { CheckIfWhilesIsNeeded check = new CheckIfWhilesIsNeeded(); root.Apply(check); return check.NeedWhileLoop; }