step8
Class gen2

java.lang.Object
  extended by step8.gen2
All Implemented Interfaces:
Visitor

public class gen2
extends Object
implements Visitor

output 2-address code for expr tree. Result is in the next temporary word to be allocated.


Field Summary
protected  HashMap _rules
          maps class to array of Rule.
protected  PrintStream out
          print action stream.
protected  Temp temp
          manage a stack of temporary locations.
 
Constructor Summary
gen2()
           
 
Method Summary
static void main(String[] args)
          read an expression from standard input and generate 2-address code.
protected  PrintStream out()
          returns print action stream.
 Object visit(int _action, Object _object)
          visits an object.
 Object visit(Object object)
          visits an object.
 Object visit0(Object object)
          visits an object, ignoring possible descendants.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

temp

protected Temp temp
manage a stack of temporary locations.


out

protected transient PrintStream out
print action stream. Can be replaced to reroute output. BUG: should be a self-flushing PrintWriter.


_rules

protected final HashMap _rules
maps class to array of Rule.

Constructor Detail

gen2

public gen2()
Method Detail

out

protected PrintStream out()
returns print action stream. Defaults to System.out.


visit

public Object visit(Object object)
             throws Exception
visits an object. This is a facade for the class search.

Specified by:
visit in interface Visitor
Parameters:
object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception
See Also:
Rule.visit(jag.Visitor, java.util.HashMap, java.lang.Object, int, java.util.List)

visit0

public Object visit0(Object object)
              throws Exception
visits an object, ignoring possible descendants. This is a facade for the class search with degree zero.

Specified by:
visit0 in interface Visitor
Parameters:
object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception
See Also:
Rule.visit(jag.Visitor, java.util.HashMap, java.lang.Object, int, java.util.List)

visit

public Object visit(int _action,
                    Object _object)
             throws Exception
visits an object.

Specified by:
visit in interface Visitor
Parameters:
_action - index.
_object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception

main

public static void main(String[] args)
                 throws Exception
read an expression from standard input and generate 2-address code.

Throws:
Exception