comp
Class Node

java.lang.Object
  |
  +--comp.Node
Direct Known Subclasses:
ArgList, AssignNode, BlockNode, ExprNode, FuncDefNode, IfNode, Module, ParmList, ReturnNode, VarDecl, WhileNode

public abstract class Node
extends java.lang.Object

The superclass of all AST Nodes.

Version:
$Id: Node.java,v 1.9 2003/01/21 01:36:07 dugan Exp $

Field Summary
(package private) static Assembler asm
           
(package private) static Scope globalScope
          There is one global scope.
(package private) static int labelCount
           
(package private) static java.util.Map strings
          A table of static strings.
 
Constructor Summary
Node()
           
 
Method Summary
 void addDefs(Scope s)
          Add any variable definitions made by this node to the given scope.
(package private) static void addString(java.lang.String label, java.lang.String s)
           
abstract  void asHTML(java.io.PrintStream out)
          For printing the AST to HTML.
(package private) abstract  java.lang.String codeGen(Scope scope, RegBank bank)
          Generate code for this node.
(package private) static java.lang.String getLabel()
           
 java.lang.String lvalue(Scope scope, RegBank bank)
          Answer a register that holds a pointer to this node's value.
static void reset()
          Clears global counters and string table.
 java.lang.String rvalue(Scope scope, RegBank bank)
          Answer a register that holds this node's value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

asm

static Assembler asm

labelCount

static int labelCount

globalScope

static Scope globalScope
There is one global scope. Not used right now.


strings

static java.util.Map strings
A table of static strings.

Constructor Detail

Node

public Node()
Method Detail

getLabel

static java.lang.String getLabel()

addString

static void addString(java.lang.String label,
                      java.lang.String s)

reset

public static void reset()
Clears global counters and string table.


codeGen

abstract java.lang.String codeGen(Scope scope,
                                  RegBank bank)
Generate code for this node. If the code is an expression it should return a register name that holds the result. Otherwise null.


addDefs

public void addDefs(Scope s)
Add any variable definitions made by this node to the given scope.


asHTML

public abstract void asHTML(java.io.PrintStream out)
For printing the AST to HTML.


lvalue

public java.lang.String lvalue(Scope scope,
                               RegBank bank)
Answer a register that holds a pointer to this node's value.


rvalue

public java.lang.String rvalue(Scope scope,
                               RegBank bank)
Answer a register that holds this node's value.