com.joanju.cg.bytecode
Class BuiltinfuncInstr

java.lang.Object
  extended by com.joanju.cg.bytecode.Bytecode
      extended by com.joanju.cg.bytecode.BuiltinfuncInstr

public class BuiltinfuncInstr
extends Bytecode

Built-in functions (and operators).

Because there is a real danger of getting into a feedback loop, these instructions will not update if the new value set contains more entries than the previous value set. That results in the unresolved value being added to the value set, with no further additions.

See the notes at the end of this file for further thoughts and considerations.


Field Summary
 
Fields inherited from class com.joanju.cg.bytecode.Bytecode
address, cuid, instrSet, nodeNum, xrefs
 
Constructor Summary
BuiltinfuncInstr()
           
BuiltinfuncInstr(int cuid, int address)
           
 
Method Summary
 void addWhereUsed(int addr)
          Called by the code generator if this expression term is used by another instruction.
 void calcValueSets()
          Calculate the value sets for the instruction.
 java.util.ArrayList<java.lang.Integer> getExpressionSources()
          Get the addresses of the sources for the expressions used in this instruction.
 Opcode getOpcode()
           
 java.util.HashSet<java.lang.Integer> getValues()
          Get the set of values for this instruction.
 java.util.HashSet<java.lang.Integer> getWhereUsed()
          As an expression term, this instruction's values are used by zero or one other instruction.
 void setInstructionSet(InstructionSet is)
          At the time this is added to the InstructionSet, we determine if this instruction is recalcOK.
protected  void setValuesFromByteStream(java.io.DataInputStream in)
           
 void stringConcat(Bytecode rval1, Bytecode rval2)
          Set the arguments for string concatenation.
 void substring(Bytecode stringSource, java.util.ArrayList<JPNode> funcArgs)
          Set the arguments for the SUBSTRING function.
 void ternaryIfOp(Bytecode rval1, Bytecode rval2)
          Set the arguments for the ternary IF operator.
 java.lang.String toStringFromComments(InstructionSet instrs)
          All Bytecode instruction subclasses should override this eventually.
 java.lang.String toStringFromData()
          All Bytecode instruction subclasses should override this eventually.
protected  void writeValuesToByteStream(java.io.DataOutputStream out)
           
 
Methods inherited from class com.joanju.cg.bytecode.Bytecode
addSource, beforeWrite, calcValuesAgain, compareTo, equals, fetchBytesFromDB, fetchInCu, generateDataForDB, getAddress, getCuID, getNodeNum, getSources, getValuesCalcLocal, getXrefs, hashCode, initData, isDataModified, isFromDB, setAddress, setCuID, setDataBytesFromDB, setDataModified, setFromDB, setNodeNum, shouldLoadData, sourcesForXrefTarget, storeIfModified, toString, toStringFromName, toStringFromSet
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BuiltinfuncInstr

public BuiltinfuncInstr()

BuiltinfuncInstr

public BuiltinfuncInstr(int cuid,
                        int address)
Method Detail

addWhereUsed

public void addWhereUsed(int addr)
                  throws java.sql.SQLException,
                         java.io.IOException
Called by the code generator if this expression term is used by another instruction.

Overrides:
addWhereUsed in class Bytecode
Throws:
java.sql.SQLException
java.io.IOException

calcValueSets

public void calcValueSets()
                   throws java.sql.SQLException,
                          java.io.IOException
Description copied from class: Bytecode
Calculate the value sets for the instruction.

Called during build, build-recalc, checkvals, and checkvals-recalc. Implementations should only build from external values once. Calculates which xref records are needed as well.

IMPORTANT: Should only ever be called for instructions belonging to an InstructionSet.

Specified by:
calcValueSets in class Bytecode
Throws:
java.sql.SQLException
java.io.IOException

getExpressionSources

public java.util.ArrayList<java.lang.Integer> getExpressionSources()
Get the addresses of the sources for the expressions used in this instruction. For string concat and ternary IF, it is two string source addresses. For substring, it is just the one string source address - no info about the start/length integer parts of the substring expression.


getOpcode

public Opcode getOpcode()
Specified by:
getOpcode in class Bytecode

getValues

public java.util.HashSet<java.lang.Integer> getValues()
                                               throws java.sql.SQLException,
                                                      java.io.IOException
Description copied from class: Bytecode
Get the set of values for this instruction. Should be overridden by most subclasses. This default implementation returns a set containing one Layout.UNRESOLVED_VALUE.

Overrides:
getValues in class Bytecode
Throws:
java.sql.SQLException
java.io.IOException

getWhereUsed

public java.util.HashSet<java.lang.Integer> getWhereUsed()
                                                  throws java.sql.SQLException,
                                                         java.io.IOException
As an expression term, this instruction's values are used by zero or one other instruction.

Overrides:
getWhereUsed in class Bytecode
Throws:
java.sql.SQLException
java.io.IOException

setInstructionSet

public void setInstructionSet(InstructionSet is)
At the time this is added to the InstructionSet, we determine if this instruction is recalcOK.

Overrides:
setInstructionSet in class Bytecode

setValuesFromByteStream

protected void setValuesFromByteStream(java.io.DataInputStream in)
                                throws java.io.IOException
Specified by:
setValuesFromByteStream in class Bytecode
Throws:
java.io.IOException

stringConcat

public void stringConcat(Bytecode rval1,
                         Bytecode rval2)
Set the arguments for string concatenation. Called by the code generator.


substring

public void substring(Bytecode stringSource,
                      java.util.ArrayList<JPNode> funcArgs)
Set the arguments for the SUBSTRING function. Called by the code generator.


ternaryIfOp

public void ternaryIfOp(Bytecode rval1,
                        Bytecode rval2)
Set the arguments for the ternary IF operator. Called by the code generator.


toStringFromComments

public java.lang.String toStringFromComments(InstructionSet instrs)
                                      throws java.sql.SQLException
Description copied from class: Bytecode
All Bytecode instruction subclasses should override this eventually.

Overrides:
toStringFromComments in class Bytecode
Returns:
"" if not overridden.
Throws:
java.sql.SQLException

toStringFromData

public java.lang.String toStringFromData()
Description copied from class: Bytecode
All Bytecode instruction subclasses should override this eventually.

Overrides:
toStringFromData in class Bytecode
Returns:
"" if not overridden.

writeValuesToByteStream

protected void writeValuesToByteStream(java.io.DataOutputStream out)
                                throws java.io.IOException
Specified by:
writeValuesToByteStream in class Bytecode
Throws:
java.io.IOException


Copyright © 2008 Joanju Software. All Rights Reserved.