

Definition at line 37 of file builder.cc.
Public Member Functions | |
| Builder (Vm *) | |
| virtual | ~Builder () |
| virtual bool | hasError () const |
| virtual void | errorDetected () |
| called if error is detected | |
| virtual void | glVar (EToken type, Token id) |
| define global variable | |
| virtual void | fncDeclInit (EToken type, Token id) |
| fnc decl detected | |
| virtual void | fncDeclArg (EToken type) |
| fnc decl arg | |
| virtual void | fncDecl () |
| fnc decl complete | |
| virtual void | fncDefInit (EToken type, Token id) |
| fnc def detected | |
| virtual void | fncDefArg (EToken type, Token id) |
| fnc def arg | |
| virtual void | fncDefVar (EToken type, Token id) |
| fnc local variable | |
| virtual void | fncDefBody () |
| fnc body | |
| virtual void | fncDef () |
| fnc def complete | |
| virtual void | assign (Token token) |
| assign command | |
| virtual void | ifEnter (Token token) |
| if statement, if part | |
| virtual void | ifElse () |
| if statement, else part | |
| virtual void | ifLeave () |
| if statement complete | |
| virtual void | whileInit (Token token) |
| while, B_EXPR follows | |
| virtual void | whileEnter () |
| while, CMD_LIST follows | |
| virtual void | whileLeave () |
| while statement complete | |
| virtual void | pushToken (Token token) |
| push token | |
| virtual void | evalUnOp (Token token) |
| eval unary operator | |
| virtual void | evalBinOp (Token token) |
| eval binary operator | |
| virtual void | fncCall (Token id, int argsToPop, bool pushResult) |
| virtual void | fncCallPrint (Token id, EToken valType) |
Private Types | |
| typedef TBlock * | TBlockStack |
| typedef Value::VType * | TTypeStack |
Private Member Functions | |
| PVar | createVar (EToken type, Token id) |
| common code for variable creation | |
| bool | appendCmd (PCmd) |
| append given command to current stack top | |
| bool | chkBlockStack () |
| return true if stack is not empty, print error otherwise | |
| void | pushTypeToStack (Value::VType) |
| push type to stack | |
| Value::VType | popTypeFromStack (const Token &) |
| pop type from stack, V_NULL if empty | |
| void | chkTypeOnTop (Value::VType type, const Token &) |
| pop type from stack and compare with given type | |
Private Attributes | |
| Vm * | vm_ |
| virtual machine being built | |
| bool | hasError_ |
| true if any error occurred | |
| FncDeclaration * | fncDecl_ |
| pointer to declaration being built, or 0 if not building declaration | |
| FncDefinition * | fncDef_ |
| pointer to definition being built, or 0 if not building definition | |
| CmdFactory | cmdFactory_ |
| common factory for virtual machine commands creation | |
| TBlockStack | blockStack_ |
| stack for blocks of commands | |
| TTypeStack | typeStack_ |
| stack for expression types | |
Classes | |
| struct | TBlock |
typedef TBlock* TBlockStack [private] |
Definition at line 72 of file builder.cc.
typedef Value::VType* TTypeStack [private] |
Definition at line 75 of file builder.cc.
Definition at line 94 of file builder.cc.
Referenced by BuilderFactory::createBuilder().

| ~Builder | ( | ) | [virtual] |
| virtual bool hasError | ( | ) | const [inline, virtual] |
Return true if any error was detected.
Implements IErrorSensitive.
Definition at line 41 of file builder.cc.
References hasError_.
| void errorDetected | ( | ) | [virtual] |
called if error is detected
Implements IBuilder.
Definition at line 108 of file builder.cc.
References blockStack_, fncDecl_, fncDef_, and hasError_.
define global variable
Implements IBuilder.
Definition at line 118 of file builder.cc.
References VarSet::add(), createVar(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, Vm::fileName, hasError_, Token::lineno, and vm_.

fnc decl detected
Implements IBuilder.
Definition at line 133 of file builder.cc.
References createVar(), StreamDecorator::E_WARNING, Vm::fileName, fncDecl_, and vm_.

| void fncDeclArg | ( | EToken | type | ) | [virtual] |
fnc decl arg
Implements IBuilder.
Definition at line 147 of file builder.cc.
References VarSet::add(), FncDeclaration::args, createVar(), StreamDecorator::E_WARNING, Vm::fileName, fncDecl_, and vm_.

| void fncDecl | ( | ) | [virtual] |
fnc decl complete
Implements IBuilder.
Definition at line 159 of file builder.cc.
References FncSet::addDeclaration(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, Vm::fileName, fncDecl_, FncSet::getDeclaration(), hasError_, Token::lineno, FncDeclaration::self, and vm_.

fnc def detected
Implements IBuilder.
Definition at line 177 of file builder.cc.
References createVar(), StreamDecorator::E_WARNING, Vm::fileName, fncDef_, and vm_.

fnc def arg
Implements IBuilder.
Definition at line 191 of file builder.cc.
References VarSet::add(), FncDeclaration::args, createVar(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, StreamDecorator::E_WARNING, Vm::fileName, fncDef_, hasError_, Token::lineno, Var::name, FncDeclaration::self, and vm_.

fnc local variable
Implements IBuilder.
Definition at line 218 of file builder.cc.
References VarSet::add(), FncDeclaration::args, createVar(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, StreamDecorator::E_WARNING, Vm::fileName, fncDef_, hasError_, Token::lineno, Var::name, FncDeclaration::self, FncDefinition::vars, and vm_.

| void fncDefBody | ( | ) | [virtual] |
fnc body
Implements IBuilder.
Definition at line 256 of file builder.cc.
References FncSet::addDeclaration(), blockStack_, FncDefinition::cmdList, Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, StreamDecorator::E_WARNING, Vm::fileName, fncDef_, FncSet::getDeclaration(), FncSet::getDefinition(), hasError_, Token::lineno, FncDeclaration::self, and vm_.

| void fncDef | ( | ) | [virtual] |
fnc def complete
Implements IBuilder.
Definition at line 293 of file builder.cc.
References FncSet::addDefinition(), blockStack_, chkBlockStack(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_WARNING, Vm::fileName, fncDef_, hasError_, FncDeclaration::self, and vm_.

| void assign | ( | Token | token | ) | [virtual] |
assign command
Implements IBuilder.
Definition at line 312 of file builder.cc.
References appendCmd(), chkTypeOnTop(), cmdFactory_, CmdFactory::createAssign(), StreamDecorator::E_WARNING, Vm::fileName, fncDef_, and vm_.

| void ifEnter | ( | Token | token | ) | [virtual] |
if statement, if part
Implements IBuilder.
Definition at line 322 of file builder.cc.
References blockStack_, chkTypeOnTop(), and Value::V_BOOL.

| void ifElse | ( | ) | [virtual] |
if statement, else part
Implements IBuilder.
Definition at line 328 of file builder.cc.
References blockStack_, chkBlockStack(), and Builder::TBlock::first.

| void ifLeave | ( | ) | [virtual] |
if statement complete
Implements IBuilder.
Definition at line 337 of file builder.cc.
References appendCmd(), blockStack_, chkBlockStack(), cmdFactory_, CmdFactory::createIf(), Builder::TBlock::first, and Builder::TBlock::second.

| void whileInit | ( | Token | token | ) | [virtual] |
while, B_EXPR follows
Implements IBuilder.
Definition at line 357 of file builder.cc.
References blockStack_.
| void whileEnter | ( | ) | [virtual] |
while, CMD_LIST follows
Implements IBuilder.
Definition at line 362 of file builder.cc.
References blockStack_, chkBlockStack(), and Builder::TBlock::first.

| void whileLeave | ( | ) | [virtual] |
while statement complete
Implements IBuilder.
Definition at line 371 of file builder.cc.
References appendCmd(), blockStack_, chkBlockStack(), cmdFactory_, CmdFactory::createWhile(), Builder::TBlock::first, and Builder::TBlock::second.

| void pushToken | ( | Token | token | ) | [virtual] |
push token
Implements IBuilder.
Definition at line 391 of file builder.cc.
References appendCmd(), cmdFactory_, CmdFactory::createPush(), StreamDecorator::E_WARNING, Vm::fileName, fncDef_, pushTypeToStack(), and vm_.

| void evalUnOp | ( | Token | token | ) | [virtual] |
eval unary operator
Implements IBuilder.
Definition at line 401 of file builder.cc.
References appendCmd(), cmdFactory_, CmdFactory::createUnary(), StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, ETOKEN_KW_NOT, ETOKEN_OP_MINUS, Vm::fileName, hasError_, popTypeFromStack(), pushTypeToStack(), Token::type, Value::V_BOOL, Value::V_DOUBLE, Value::V_INT, and vm_.

| void evalBinOp | ( | Token | token | ) | [virtual] |
eval binary operator
Implements IBuilder.
Definition at line 415 of file builder.cc.
References appendCmd(), cmdFactory_, CmdFactory::createBinary(), StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, Vm::fileName, hasError_, popTypeFromStack(), pushTypeToStack(), Value::V_NULL, and vm_.

| void fncCall | ( | Token | id, | |
| int | argsToPop, | |||
| bool | pushResult | |||
| ) | [virtual] |
function call
| id | token initiating function call | |
| argsToPop | count of arguments to pop from stack and give them to function | |
| pushResult | true if function return value is going to be used |
Implements IBuilder.
Definition at line 430 of file builder.cc.
References CalleeSet::add(), appendCmd(), FncDeclaration::args, Vm::calleeSet, chkTypeOnTop(), cmdFactory_, CmdFactory::createCall(), CmdFactory::createInput(), Var::defined, StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, StreamDecorator::E_WARNING, Vm::fileName, Vm::fncSet, FncSet::getDeclaration(), hasError_, Token::lineno, pushTypeToStack(), FncDeclaration::self, VarSet::size(), Value::type, Value::V_DOUBLE, Value::V_INT, Value::V_STRING, Var::value, and vm_.

print function call
| id | token initiating function call | |
| valType | type of expression expected by print function |
Implements IBuilder.
Definition at line 482 of file builder.cc.
References appendCmd(), chkTypeOnTop(), cmdFactory_, and CmdFactory::createPrint().

common code for variable creation
Definition at line 488 of file builder.cc.
References StreamDecorator::E_WARNING, ETOKEN_KW_DOUBLE, ETOKEN_KW_INT, ETOKEN_KW_STRING, ETOKEN_KW_VOID, Vm::fileName, Value::V_DOUBLE, Value::V_INT, Value::V_NULL, Value::V_STRING, and vm_.
Referenced by fncDeclArg(), fncDeclInit(), fncDefArg(), fncDefInit(), fncDefVar(), and glVar().

| bool appendCmd | ( | PCmd | cmd | ) | [private] |
append given command to current stack top
Definition at line 507 of file builder.cc.
References blockStack_, chkBlockStack(), hasError_, and Builder::TBlock::second.
Referenced by assign(), evalBinOp(), evalUnOp(), fncCall(), fncCallPrint(), ifLeave(), pushToken(), and whileLeave().


| bool chkBlockStack | ( | ) | [private] |
return true if stack is not empty, print error otherwise
Definition at line 519 of file builder.cc.
References blockStack_, Var::defined, StreamDecorator::E_WARNING, Vm::fileName, fncDef_, FncDeclaration::self, and vm_.
Referenced by appendCmd(), fncDef(), ifElse(), ifLeave(), whileEnter(), and whileLeave().

| void pushTypeToStack | ( | Value::VType | type | ) | [private] |
push type to stack
Definition at line 526 of file builder.cc.
References StreamDecorator::C_LIGHT_CYAN, StreamDecorator::C_NO_COLOR, and typeStack_.
Referenced by evalBinOp(), evalUnOp(), fncCall(), and pushToken().

| Value::VType popTypeFromStack | ( | const Token & | t | ) | [private] |
pop type from stack, V_NULL if empty
Definition at line 533 of file builder.cc.
References StreamDecorator::C_LIGHT_CYAN, StreamDecorator::C_NO_COLOR, StreamDecorator::E_WARNING, Vm::fileName, typeStack_, Value::V_NULL, and vm_.
Referenced by chkTypeOnTop(), evalBinOp(), and evalUnOp().

| void chkTypeOnTop | ( | Value::VType | type, | |
| const Token & | t | |||
| ) | [private] |
pop type from stack and compare with given type
Definition at line 547 of file builder.cc.
References StreamDecorator::E_ERROR, StreamDecorator::E_NOTE, Vm::fileName, hasError_, popTypeFromStack(), and vm_.
Referenced by assign(), fncCall(), fncCallPrint(), and ifEnter().


virtual machine being built
Definition at line 65 of file builder.cc.
Referenced by assign(), chkBlockStack(), chkTypeOnTop(), createVar(), evalBinOp(), evalUnOp(), fncCall(), fncDecl(), fncDeclArg(), fncDeclInit(), fncDef(), fncDefArg(), fncDefBody(), fncDefInit(), fncDefVar(), glVar(), popTypeFromStack(), and pushToken().
bool hasError_ [private] |
true if any error occurred
Definition at line 66 of file builder.cc.
Referenced by appendCmd(), chkTypeOnTop(), errorDetected(), evalBinOp(), evalUnOp(), fncCall(), fncDecl(), fncDef(), fncDefArg(), fncDefBody(), fncDefVar(), glVar(), and hasError().
FncDeclaration* fncDecl_ [private] |
pointer to declaration being built, or 0 if not building declaration
Definition at line 67 of file builder.cc.
Referenced by errorDetected(), fncDecl(), fncDeclArg(), fncDeclInit(), and ~Builder().
FncDefinition* fncDef_ [private] |
pointer to definition being built, or 0 if not building definition
Definition at line 68 of file builder.cc.
Referenced by assign(), chkBlockStack(), errorDetected(), fncDef(), fncDefArg(), fncDefBody(), fncDefInit(), fncDefVar(), pushToken(), and ~Builder().
CmdFactory cmdFactory_ [private] |
common factory for virtual machine commands creation
Definition at line 69 of file builder.cc.
Referenced by assign(), evalBinOp(), evalUnOp(), fncCall(), fncCallPrint(), ifLeave(), pushToken(), and whileLeave().
TBlockStack blockStack_ [private] |
stack for blocks of commands
Definition at line 73 of file builder.cc.
Referenced by appendCmd(), chkBlockStack(), errorDetected(), fncDef(), fncDefBody(), ifElse(), ifEnter(), ifLeave(), whileEnter(), whileInit(), and whileLeave().
TTypeStack typeStack_ [private] |
stack for expression types
Definition at line 76 of file builder.cc.
Referenced by popTypeFromStack(), and pushTypeToStack().
1.5.4