|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectec.gp.GPNode
ec.gp.ERC
ac.essex.ooechs.ecj.ecj2java.nodes.ParseableERC
public abstract class ParseableERC
ParseableERC is an adapter class that serves two functions:
It adapts a number of unpleasant methods in the ERC class that don't need to be altered often (if at all).
It implements the functionality required by ParseableNode which allows the node to be converted into pure java.
Implementation is easy - just take your existing ERC and extend ParseableERC instead of ERC. The only required methods are setNumber() and name().
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, provided that any use properly credits the author. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org
| Field Summary | |
|---|---|
protected int |
type
|
protected double |
value
|
(package private) java.lang.String |
variableName
|
| Fields inherited from class ec.gp.ERC |
|---|
ERC_PREFIX |
| Fields inherited from class ec.gp.GPNode |
|---|
argposition, children, constraints, GPNODEPRINTTAB, MAXPRINTBYTES, NODESEARCH_ALL, NODESEARCH_CUSTOM, NODESEARCH_NONTERMINALS, NODESEARCH_TERMINALS, P_NODE, P_NODECONSTRAINTS, parent, REPLACEMENT_CHAR, SITUATION_MUTATION, SITUATION_NEWIND |
| Fields inherited from interface ac.essex.ooechs.ecj.ecj2java.nodes.ParseableNode |
|---|
BOOLEAN, DOUBLE, ERC, FUNCTION, INT, RETURN, VOID |
| Constructor Summary | |
|---|---|
ParseableERC()
|
|
| Method Summary | |
|---|---|
int |
countChildren()
Returns how many children this node has |
boolean |
decode(ec.util.DecodeReturn dret)
|
java.lang.String |
encode()
|
void |
eval(ec.EvolutionState state,
int thread,
ec.gp.GPData input,
ec.gp.ADFStack stack,
ec.gp.GPIndividual individual,
ec.Problem problem)
|
ParseableNode |
getChild(int index)
Gets the child of this node at a given index. |
java.lang.String |
getJavaCode()
Writes out the java for this node |
java.lang.String |
getLineComment()
There may be a line comment associated with this piece of code. |
int |
getType()
Returns what kind of node this is. |
java.lang.String |
getValue()
|
java.lang.String |
getVariableName()
When the java writer uses this node, it may use a variable name to describe it. |
void |
mutateERC(ec.EvolutionState state,
int thread)
Mutates the node's "value". |
abstract java.lang.String |
name()
The name of the class that ECK uses. |
boolean |
nodeEquals(ec.gp.GPNode node)
|
int |
nodeHashCode()
|
void |
readNode(ec.EvolutionState state,
java.io.DataInput dataInput)
|
void |
resetNode(ec.EvolutionState state,
int thread)
|
abstract double |
setNumber(ec.EvolutionState state,
int thread)
Set the value of the ERC here |
void |
setType(int type)
Set the node type |
void |
setValue(double value)
|
void |
setVariableName(java.lang.String name)
Attaches a variable name to this node, used by JavaWriter |
java.lang.String |
toStringForHumans()
|
void |
writeNode(ec.EvolutionState state,
java.io.DataOutput dataOutput)
|
| Methods inherited from class ec.gp.ERC |
|---|
checkConstraints, readNode, toString |
| Methods inherited from class ec.gp.GPNode |
|---|
atDepth, cloneReplacing, cloneReplacing, cloneReplacing, cloneReplacingAtomic, cloneReplacingAtomic, cloneReplacingAtomicSimple, cloneReplacingAtomicSimple, cloneReplacingNoSubclone, cloneReplacingNoSubcloneSimple, cloneReplacingSimple, cloneReplacingSimple, cloneReplacingSimple, constraints, contains, defaultBase, depth, errorInfo, makeCTree, makeLatexTree, nodeEquivalentTo, nodeInPosition, numNodes, numNodes, parentType, printNode, printNode, printNodeForHumans, printRootedTree, printRootedTree, printRootedTreeForHumans, protoClone, protoCloneSimple, readRootedTree, readRootedTree, replaceWith, rootedTreeEquals, rootedTreeHashCode, rootParent, setup, swapCompatibleWith, toStringForError, writeRootedTree |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ac.essex.ooechs.ecj.ecj2java.nodes.ParseableNode |
|---|
getObjectType |
| Field Detail |
|---|
protected int type
protected double value
java.lang.String variableName
| Constructor Detail |
|---|
public ParseableERC()
| Method Detail |
|---|
public abstract double setNumber(ec.EvolutionState state,
int thread)
public void mutateERC(ec.EvolutionState state,
int thread)
mutateERC in class ec.gp.ERCpublic abstract java.lang.String name()
name in class ec.gp.ERCpublic ParseableNode getChild(int index)
ParseableNode
getChild in interface ParseableNodepublic int getType()
ParseableNode
getType in interface ParseableNodepublic java.lang.String getValue()
public void setValue(double value)
public int countChildren()
ParseableNode
countChildren in interface ParseableNodepublic java.lang.String getVariableName()
getVariableName in interface ParseableNodepublic void setVariableName(java.lang.String name)
setVariableName in interface ParseableNodepublic java.lang.String getJavaCode()
ParseableNode
getJavaCode in interface ParseableNodepublic java.lang.String getLineComment()
ParseableNode
getLineComment in interface ParseableNodepublic void setType(int type)
ParseableNode
setType in interface ParseableNode
public void resetNode(ec.EvolutionState state,
int thread)
resetNode in class ec.gp.ERCpublic boolean nodeEquals(ec.gp.GPNode node)
nodeEquals in class ec.gp.ERC
public void readNode(ec.EvolutionState state,
java.io.DataInput dataInput)
throws java.io.IOException
readNode in class ec.gp.ERCjava.io.IOException
public void writeNode(ec.EvolutionState state,
java.io.DataOutput dataOutput)
throws java.io.IOException
writeNode in class ec.gp.ERCjava.io.IOExceptionpublic java.lang.String encode()
encode in class ec.gp.ERCpublic boolean decode(ec.util.DecodeReturn dret)
decode in class ec.gp.ERCpublic java.lang.String toStringForHumans()
toStringForHumans in class ec.gp.ERC
public void eval(ec.EvolutionState state,
int thread,
ec.gp.GPData input,
ec.gp.ADFStack stack,
ec.gp.GPIndividual individual,
ec.Problem problem)
eval in class ec.gp.GPNodepublic int nodeHashCode()
nodeHashCode in class ec.gp.ERC
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||