comp
Class VarDecl

java.lang.Object
  |
  +--comp.Node
        |
        +--comp.VarDecl

class VarDecl
extends Node

Represents a variable declaration. A variable decalaration is a type and a list of names that are of that type. Optionally, it may also have an initializer.


Field Summary
(package private)  AssignNode initializer
           
(package private)  boolean isExtern
           
(package private)  java.util.List names
           
(package private)  Type type
           
(package private)  java.lang.String typeName
           
 
Fields inherited from class comp.Node
asm, globalScope, labelCount, strings
 
Constructor Summary
(package private) VarDecl(java.lang.String name)
          A new variable declaration of indeterminate type.
(package private) VarDecl(java.lang.String typeName, java.lang.String name)
          A variable declaration of given type and name.
(package private) VarDecl(java.lang.String typeName, java.lang.String name, ExprNode init)
          A variable declaration with the given initializer expression.
(package private) VarDecl(java.lang.String typeName, java.lang.String name, int length)
          An array variable declaration .
 
Method Summary
 void add(java.lang.String id)
          Add another name to the list.
 void addDefs(Scope s)
          Add any variable definitions made by this node to the given scope.
 void asHTML(java.io.PrintStream out)
          Process this node.
 java.lang.String codeGen(Scope scope, RegBank bank)
          Generally do nothing, unless I have an initializer.
 void dumpAsGlobal()
          Dump global as global text.
 void initWith(ExprNode e)
          Set the initializer expression.
 void setType(java.lang.String typeName)
          Set the type.
 java.lang.String toString()
           
 
Methods inherited from class comp.Node
addString, getLabel, lvalue, reset, rvalue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

names

java.util.List names

typeName

java.lang.String typeName

type

Type type

initializer

AssignNode initializer

isExtern

boolean isExtern
Constructor Detail

VarDecl

VarDecl(java.lang.String name)
A new variable declaration of indeterminate type.


VarDecl

VarDecl(java.lang.String typeName,
        java.lang.String name)
A variable declaration of given type and name.


VarDecl

VarDecl(java.lang.String typeName,
        java.lang.String name,
        int length)
An array variable declaration .


VarDecl

VarDecl(java.lang.String typeName,
        java.lang.String name,
        ExprNode init)
A variable declaration with the given initializer expression.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

initWith

public void initWith(ExprNode e)
Set the initializer expression.


setType

public void setType(java.lang.String typeName)
Set the type.


add

public void add(java.lang.String id)
Add another name to the list.


codeGen

public java.lang.String codeGen(Scope scope,
                                RegBank bank)
Generally do nothing, unless I have an initializer.

Specified by:
codeGen in class Node

addDefs

public void addDefs(Scope s)
Description copied from class: Node
Add any variable definitions made by this node to the given scope.

Overrides:
addDefs in class Node

dumpAsGlobal

public void dumpAsGlobal()
Dump global as global text. Only makes sense for global variables.


asHTML

public void asHTML(java.io.PrintStream out)
Process this node.

Specified by:
asHTML in class Node