Example #1
0
 private void installClass(CgenNode nd) {
   AbstractSymbol name = nd.getName();
   if (probe(name) != null) return;
   nds.addElement(nd);
   nodeMap.put(nd.getName(), nd);
   addId(name, nd);
 }
Example #2
0
  /* given a class and a method, return the offset to the class's dispatch table */
  public int getMethodOffset(AbstractSymbol clazz, AbstractSymbol method) {
    CgenNode nd = nodeMap.get(clazz);

    if (Flags.cgen_debug) System.out.printf("getMethodOffset %s %s\n", clazz, method);

    if (!nd.methOffsets.containsKey(method)) return getMethodOffset(nd.getParent(), method);
    else return nd.methOffsets.get(method);
  }
Example #3
0
 /* get the depth of the class in the inheritance tree */
 public int getDepth(AbstractSymbol clazz) {
   int depth = 0;
   CgenNode nd = nodeMap.get(clazz);
   while (nd.name != TreeConstants.Object_) {
     nd = nd.getParentNode();
     depth++;
   }
   return depth;
 }
Example #4
0
  private void codeClassMethods() {
    str.println("\n# Class Methods");
    for (Object obj : nds) {

      // code each of the class method
      CgenNode nd = (CgenNode) obj;
      nd.codeClassMethod(str);
    }
  }
Example #5
0
  private void codeObjInits() {
    str.println("\n# Object Initializers");
    for (Object obj : nds) {
      CgenNode nd = (CgenNode) obj;

      // code object initailzers (constructor method)
      CgenSupport.emitInitRef(nd.getName(), str);
      str.print(CgenSupport.LABEL);
      nd.codeObjInit(str);
    }
  }
Example #6
0
  private void codeDispTables() {
    str.println("\n# Dispatch Tables");
    for (Object obj : nds) {
      CgenNode nd = (CgenNode) obj;

      // code class method reference
      CgenSupport.emitDispTableRef(nd.getName(), str);
      str.print(CgenSupport.LABEL);
      nd.codeDispTab(str);
    }
  }
Example #7
0
  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);
    }
  }
Example #8
0
  private void codeClassNameTable() {
    str.println("\n# Class Name Table");
    str.print(CgenSupport.CLASSNAMETAB + CgenSupport.LABEL);

    // code the name of each class
    for (Object obj : nds) {
      str.print(CgenSupport.WORD);
      ((CgenNode) obj).getNameStrSym().codeRef(str);
      str.println("\t# " + obj);
    }
  }
Example #9
0
 /* given a class and an attribute, return the offset to the object reference */
 public int getAttrOffset(AbstractSymbol clazz, AbstractSymbol a) {
   CgenNode nd = nodeMap.get(clazz);
   if (!nd.attrOffsets.containsKey(a)) return getAttrOffset(nd.getParent(), a);
   else return nd.attrOffsets.get(a);
 }
Example #10
0
 private void setRelations(CgenNode nd) {
   CgenNode parent = (CgenNode) probe(nd.getParent());
   nd.setParentNd(parent);
   parent.addChild(nd);
 }