Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class MethodBuilder
Class MethodBuilder
Description:
This is a compiler utility that helps maintain
symbol table information and other state during
method compilation.
Public Methods:
-
MethodBuilder
(const ClassPtr & currentClass = gNil);
-
-
~MethodBuilder
();
-
-
void
buildBlockFrom
(const MethodBuilder & m);
-
Create Methods
-
void
createTemporary
(const String & tempName);
-
Given a string tempName, I create and add a new entry in the current
scope's temporary symboltable.
-
void
createArgument
(const String & argName);
-
Given a string argName, I create and add a new entry in the current
scope's temporary symboltable.
Pop Methods
-
void
popStackTop
();
-
I generate a "pop the stack" bytecode.
-
void
pop
(const String & variable);
-
Given a variable name, I get the index of the variable using
findVariable(), and generate the appropriate pop bytecodes.
Q: what if not found? A: Oh well...
-
void
store
(const String & variable);
-
Given a variable name, I get the index of the variable using
findVariable(), and generate the appropriate store bytecodes.
Q: what if not found? A: Oh well...
Push Methods
-
void
pushActiveContext
();
-
-
void
jump
(const SInteger & size);
-
-
const Boolean &
push
(const String & tempName);
-
Given a string tempName, I get the index of the variable using
findVariable(), and generate the appropriate push bytecodes.
Q: What if not found? A: "oh well"
Returns true if selector == "super", false otherwise.
-
void
pushLiteral
(const String & string, const ObjectPtr & literal);
-
Given a string and an ObjectPointer, I get the index of the variable using
findLiteral(). If it is not found, then I add the literal using addLiteral().
Once I have a valid index, I generate the appropriate push bytecodes.
-
void
send
(const String & selector, const Boolean toSuper, const UInteger & argCount);
-
Given a method selector, I get the index for the selector on the
literal frame using findLiteral(). If it is not found, then I add
the selector using addLiteral. Then I generate the appropriate
send bytecodes depending on toSuper.
-
void
reTurn
();
-
I generate the appropriate return bytecode depending on the state
of the boolean inBlock.
Utility Methods
-
MethodPtr
buildMethod
();
-
I validate the state of myself, and when I am done (and still OK) I
create and return a new CompiledMethod object.
-
void
appendBlock
(const MethodBuilder & blockMB);
-
Given another methodbuilder, blockMB, I merge the contents of
blockMB into myself. This should only be used for block context
compiling.
-
void
primitive
(const SInteger number);
-
I set the primitive number otherwise defaults to zero.
-
SInteger
primitive
();
-
Should I be protected?
-
void
selector
(const String & selector);
-
I set the method's selector.
-
UInteger
bytecount
();
-
I am the accessor for the current bytestore's bytecount.
-
ByteStore
subset
(const UInteger & start, const UInteger & stop);
-
I am a utility to access and copy a substring of the current
bytestore's bytestream from byte #start to byte #stop.
-
void
appendBytes
(const ByteStore & bytestore);
-
Given a string of bytecodes (which may have zero chars), I append the
bytes to the current bytestore.
NEEDED: myBytes
Services
Protected Methods:
-
const ByteStore &
bytes
();
-
-
ByteStore &
bytes
();
-
-
const ArrayPtr &
temporaries
();
-
-
ArrayPtr &
temporaries
();
-
-
const DictPtr &
literals
();
-
-
DictPtr &
literals
();
-
-
const ClassPtr &
currentClass
();
-
-
ClassPtr &
currentClass
();
-
-
UInteger &
argCount
();
-
-
const UInteger &
argCount
();
-
-
UInteger &
tempCount
();
-
-
const UInteger &
tempCount
();
-
-
Boolean &
inBlock
();
-
-
const Boolean &
inBlock
();
-
-
Boolean
findVariable
(const SymbolPtr & key, UInteger & type, UInteger & index );
-
-
Boolean
findLiteral
(const SymbolPtr & key, UInteger & index);
-
Given a key to search for, I search for it through the literal symboltable.
If I find it, I set index to the appropriate value and return true.
Otherwise, I return false and leave index alone.
-
UInteger
addLiteral
(const SymbolPtr & key, const ObjectPtr & value);
-
I add the key/value pair to the literal symboltable and return it's index.
Data
Protected Members:
-
SInteger
myPrimitive;
-
-
String
mySelector;
-
-
ByteStore
myBytes;
-
-
Boolean
myInBlock;
-
-
Boolean
myReturnNormal;
-
-
UInteger
myTempCount;
-
-
UInteger
myArgCount;
-
NOTE: Make sure dtor/ctor un/roots the following:
-
ClassPtr
myCurrentClass;
-
-
DictPtr
myLiterals;
-
-
ArrayPtr
myTemporaries;
-
Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class MethodBuilder