//public void VisitNode(Nodes.FieldVarDecl node) //other decls stored as children //{ // node.symInfo.setTypesFromModifiers(node.modList); // this.populateTypeSpec(node.typeChild, ref node.symInfo); // foreach (string name in node.fv_list) // { // this.symTable.enter(name, node.symInfo); // } //} //public void VisitNode(Nodes.Expression node) //left OP right //{ // VisitChildren(node); // //do type check by comparing op1 and op 2 for type // if (node.left.symInfo.pType == node.right.symInfo.pType) //ptypes match // { // if (node.left.symInfo.pType == Nodes.primType.CLASS) //if both are classes // { // if (!node.left.symInfo.customTypeName.Equals(node.right.symInfo.customTypeName)) //if custom types not equal // { // Console.WriteLine("TYPES {0} AND {1} NOT EQUAL! OPERATOR: {2} ", node.left.symInfo.customTypeName, node.right.symInfo.customTypeName, node.opType); // } // } // } // else // { // Console.WriteLine("TYPES {0} and {1} NOT EQUAL! OP type: {2}", node.left.symInfo.pType, node.right.symInfo.pType, node.opType); // } // //how to handle arrays? // node.symInfo.pType = node.left.symInfo.pType; // //this.symTable.enter(node.left.) //} //public void VisitNode(Nodes.QualName node) //make signatures for Qualified Name, Literal, FIeldAccess, MethodCall, Number //{ // SymInfo sym = this.symTable.lookup(node.q_name.Last()); // if (sym != null) // if null, lookup prints an error // { // node.symInfo = sym; // } // else // { // //not implementing for now // Console.WriteLine("****Long Qualified Names currently not handled, or symbol not defined: " + // String.Join(".", node.q_name)); // } //} public void VisitNode(Nodes.MethodCall node) { if (node.getMethodName() == "WriteLine" | node.getMethodName() == "Write") { if (node.args == null) { //write.WriteLine("ldstr \"Test Hello\""); write.WriteLine("call void[mscorlib] System.Console::WriteLine()"); } else if (node.args.GetType() == typeof(Nodes.Literal)) { write.WriteLine("ldstr \"" + ((Nodes.Literal)node.args).name + "\""); write.WriteLine("call void[mscorlib] System.Console::WriteLine(string)"); } else { Console.WriteLine("Writing of expressions, vars and other types not currently handled"); } } VisitChildren(node.args); }
public void VisitNode(Nodes.MethodCall node) { if (node.getMethodName() == "WriteLine" | node.getMethodName() == "Write") { if (node.args == null) { Console.WriteLine(); } else if (node.args.GetType() == typeof(Nodes.Literal)) { Console.WriteLine(); Console.WriteLine(((Nodes.Literal)node.args).name); } else { Console.WriteLine("Writing of expressions, vars and other types not currently handled"); } } node.symInfo = this.symTable.lookup(node.getMethodName()); //has return type VisitChildren(node.args); }