|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectharpoon.Tools.PatMat.CodeGeneratorGenerator
public abstract class CodeGeneratorGenerator
CodeGeneratorGenerator generates a java program to
convert Trees into Instr sequences.
A Code Generator Generator (CGG) takes a set of instruction pattern
tiles and constructs a java source file for a utility class
containing a method codegen(TreeCode) which will
generate an HCode in Instr form from a
TreeCode. In short, a CGG generates a Code Generator.
CodeGen| Field Summary | |
|---|---|
protected Spec |
spec
The machine specification that the CodeGenerators outputted by this will target. |
| Constructor Summary | |
|---|---|
CodeGeneratorGenerator(Spec s,
String className)
Creates a CodeGeneratorGenerator. |
|
| Method Summary | |
|---|---|
void |
outputJavaFile(PrintWriter out)
Writes the Code Generator to out. |
abstract void |
outputSelectionMethod(PrintWriter out,
boolean isData)
Writes the Instruction Selection Method to out. |
protected abstract String |
producedClassType()
Returns the fully qualified name of the superclass of the generated CodeGen. |
protected String |
returnCodeStatements()
|
protected String |
returnDataStatements()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Spec spec
this will target.
| Constructor Detail |
|---|
public CodeGeneratorGenerator(Spec s,
String className)
CodeGeneratorGenerator.
s follows the standard template for
defining a machine specification.
s contains Java statements that rely
on knowledge about the class to be produced (such as
a Constructor implementation) then the class named
must match the className parameter.
CodeGeneratorGenerator and associates the
machine specification s with the newly
constructed CodeGeneratorGenerator.
s - Spec defining the machine specification
that the CodeGenerator output by this
will target.className - Formal name of the class that
this outputs.| Method Detail |
|---|
protected abstract String producedClassType()
CodeGen.
The superclass should be a subclass of
Generic.CodeGen (or Generic.CodeGen
itself.
public void outputJavaFile(PrintWriter out)
out.
out
this.
Then writes the Java source code out to out,
and flushes out after it finishes outputting
the source code.
this.spec, with the exception of
this.className.
public class this.className extends
harpoon.Backend.Generic.CodeGen.
public final Instr gen(harpoon.IR.Tree.Code tree,
harpoon.IR.Assem.InstrFactory inf).
public final Instr gen(harpoon.IR.Tree.Data tree,
harpoon.IR.Assem.InstrFactory inf).
out - Target output device for the Java source code.protected String returnCodeStatements()
protected String returnDataStatements()
public abstract void outputSelectionMethod(PrintWriter out,
boolean isData)
out.
out
out.
code, a Tree.Code
that represents the input set of Tree
HCodeElements. From this the code may
access the Frame,
TreeDerivation, and
IR.Tree.Tree objects necessary to create
assembly code Instrs using the actions
provided by a spec file.
this.spec, define variables for the action
statements in the pattern to refer to. These variables
are:Spec.ExpId objects defined in the
pattern, including the result_id and %extra Temp
objects.
HCodeElement ROOT.
This should be defined as the
IR.Tree.Tree element being analyzed. To
reference specific fields or methods of the
IR.Tree.Tree element being analyzed, one
should cast ROOT to the appropriate
subclass of IR.Tree.Tree (though this
requirement may be dropped in the future).
tree, using the information in
this.spec as a Spec.Rule tile
source, and then runs Spec.Rule.action_str
for each matching tile.
out - Target output device for the Java source code.isData - indicates if we're pattern matching code or data tables
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||