private void codeProtObjs() { str.println("\n# Prototype Objects"); for (Object obj : nds) { CgenNode nd = (CgenNode) obj; // code class attributes str.println(CgenSupport.WORD + "-1"); // GC tag CgenSupport.emitProtObjRef(nd.getName(), str); str.print(CgenSupport.LABEL); nd.codeProtObj(str); } }
/** Emits code to start the .data segment and to declare the global names. */ private void codeGlobalData() { // The following global names must be defined first. // set FP offset to be below SP by 1 fpOffset = 0; str.println("\n# Global Data"); str.print("\t.data\n" + CgenSupport.ALIGN); str.println(CgenSupport.GLOBAL + CgenSupport.CLASSNAMETAB); str.print(CgenSupport.GLOBAL); CgenSupport.emitProtObjRef(TreeConstants.Main, str); str.println(""); str.print(CgenSupport.GLOBAL); CgenSupport.emitProtObjRef(TreeConstants.Int, str); str.println(""); str.print(CgenSupport.GLOBAL); CgenSupport.emitProtObjRef(TreeConstants.Str, str); str.println(""); str.print(CgenSupport.GLOBAL); BoolConst.falsebool.codeRef(str); str.println(""); str.print(CgenSupport.GLOBAL); BoolConst.truebool.codeRef(str); str.println(""); str.println(CgenSupport.GLOBAL + CgenSupport.INTTAG); str.println(CgenSupport.GLOBAL + CgenSupport.BOOLTAG); str.println(CgenSupport.GLOBAL + CgenSupport.STRINGTAG); // We also need to know the tag of the Int, String, and Bool classes // during code generation. str.println(CgenSupport.INTTAG + CgenSupport.LABEL + CgenSupport.WORD + intclasstag); str.println(CgenSupport.BOOLTAG + CgenSupport.LABEL + CgenSupport.WORD + boolclasstag); str.println(CgenSupport.STRINGTAG + CgenSupport.LABEL + CgenSupport.WORD + stringclasstag); }
private void codeClassObjTable() { str.println("\n# Class Object Table"); str.print(CgenSupport.CLASSOBJTAB + CgenSupport.LABEL); for (Object obj : nds) { AbstractSymbol className = ((CgenNode) obj).getName(); // code prototype object reference str.print(CgenSupport.WORD); CgenSupport.emitProtObjRef(className, str); str.println(); // code initializer reference str.print(CgenSupport.WORD); CgenSupport.emitInitRef(className, str); str.println(); } }