public static AbstractNode MakeStructDeclaration(AbstractNode mods, AbstractNode id, AbstractNode body) { return(new StructDeclaration(mods, id, body)); }
public void VisitNode(AbstractNode node) { }
public virtual AbstractNode orphan() { mysib = parent = null; firstSib = this; return(this); }
public ClassBody(AbstractNode classbdy) { adoptChildren(classbdy); }
public void VisitNode(MethodDeclaration node) { stlocCount = 0; Identifier name = (Identifier)node.Child.Sib.Sib.Child; AbstractNode body = node.Child.Sib.Sib.Sib; MethodAttributes attr = (MethodAttributes)node.AttributesRef; List <string> mods = attr.Mods; AbstractNode param = null; if (((SignatureTypeDescriptor)attr.Signature).Parameters != null) { param = ((SignatureTypeDescriptor)attr.Signature).Parameters.Child; } using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { string s = ".method "; if (mods.Contains("PUBLIC")) { s += "public "; } if (mods.Contains("PRIVATE")) { s += "private "; } if (mods.Contains("STATIC")) { s += "static "; } s += attr.ReturnType.type + " "; s += name.Name; s += " ("; if (param != null) { while (param != null) { AbstractNode type = param.Child; Identifier paramName = (Identifier)type.Sib; s += type.TypeRef.type; param = param.Sib; if (param != null) { s += ", "; } } } s += ")"; sw.WriteLine(s + "\n{"); if (name.Name == "main") { sw.WriteLine(".entrypoint"); } sw.WriteLine(".maxstack 100"); if (((SignatureTypeDescriptor)attr.Signature).Parameters != null) { param = ((SignatureTypeDescriptor)attr.Signature).Parameters.Child; while (param != null) { param.Accept(this); param = param.Sib; } } } } MethodBodyVisitor visitor = new MethodBodyVisitor(); body.Accept(visitor); using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine("\nret\n}"); } } }
public ReturnStatement(AbstractNode retrn) { adoptChildren(retrn); }
public LocalItems(AbstractNode localItems) { adoptChildren(localItems); }
public MethodCall(AbstractNode name) { adoptChildren(name); }
public MethodCall(AbstractNode name, AbstractNode paramList) { adoptChildren(name); adoptChildren(paramList); }
public MethodSignature(AbstractNode name) { adoptChildren(name); }
public MethodSignature(AbstractNode name, AbstractNode paramList) { adoptChildren(name); adoptChildren(paramList); }
public ParameterList(AbstractNode parameter) : base() { adoptChildren(parameter); }
public Parameter(AbstractNode typeSpec, AbstractNode declName) : base() { adoptChildren(typeSpec); adoptChildren(declName); }
public MethodBody(AbstractNode abstractNode) { adoptChildren(abstractNode); }
public SelectionStatement(AbstractNode expr, AbstractNode stmt) { adoptChildren(expr); adoptChildren(stmt); }
public CompilationUnit(AbstractNode classDecl) { adoptChildren(classDecl); }
public IterationStatement(AbstractNode whileExpr, AbstractNode stmt) { adoptChildren(whileExpr); adoptChildren(stmt); }
public Expression(AbstractNode expr, ExprKind kind) { adoptChildren(expr); exprKind = kind; }
public LocalVariableNames(AbstractNode localVarName) { adoptChildren(localVarName); }
public Expression(AbstractNode lhs, ExprKind kind, AbstractNode rhs) { adoptChildren(lhs); adoptChildren(rhs); exprKind = kind; }
public ClassDeclaration(AbstractNode modifiers, AbstractNode identifier, AbstractNode classbody) { adoptChildren(modifiers); adoptChildren(identifier); adoptChildren(classbody); }
public Block(AbstractNode blkCode) { adoptChildren(blkCode); }
public ScanObj(int t, AbstractNode val, LexLocation loc) { this.token = t; this.yylval = val; this.yylloc = loc; }
public StructDeclaration(AbstractNode modifier, AbstractNode identifier, AbstractNode structBody) { adoptChildren(modifier); adoptChildren(identifier); adoptChildren(structBody); }
public void VisitNode(MethodCall node) { Identifier functionCall = (Identifier)node.Child.Child; AbstractNode list = node.Child.Sib; string s = ""; if (functionCall.TypeRef.GetType() == typeof(ASTBuilder.MSCorLibTypeDescriptor) && node.TypeRef.GetType() == typeof(ASTBuilder.StringTypeDescriptor)) { list.Accept(this); using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine("call " + functionCall.TypeRef.type + functionCall.Name + "(string)"); } } } else if (functionCall.TypeRef.GetType() == typeof(ASTBuilder.MSCorLibTypeDescriptor) && node.TypeRef.GetType() == typeof(ASTBuilder.IntegerTypeDescriptor)) { using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine("ldstr \"{0}\""); } } list.Accept(this); using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine("box int32"); sw.WriteLine("call void [mscorlib]System.Console::WriteLine(string, object) "); } } } else { while (list != null) { list.Accept(this); list = list.Sib; } s += "call " + functionCall.TypeRef.type + " " + functionCall.Name + "("; list = node.Child.Sib; while (list != null) { s += list.TypeRef.type; list = list.Sib; if (list != null) { s += ", "; } } s += ")"; using (FileStream fs = File.Open(GlobalVar.PATH, FileMode.Append)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(s); } } } }
public LocalVariableDeclaration(AbstractNode typeSpecifier, AbstractNode localVariableName) { adoptChildren(typeSpecifier); adoptChildren(localVariableName); }
public void VisitNode(AbstractNode node) { Console.Write("<" + node.ClassName() + ">"); }
public ArgumentList(AbstractNode expr) { adoptChildren(expr); }
public virtual AbstractNode abandonChildren() { child = null; return(this); }
public static AbstractNode MakeClassDeclaration(AbstractNode mods, AbstractNode id, AbstractNode body) { return(new ClassDeclaration(mods, id, body)); }