Objects Compiled
This commit is contained in:
parent
ba95747ef9
commit
64e1f78739
52 changed files with 384 additions and 370 deletions
|
|
@ -11,7 +11,7 @@ ExpressionChild* Expression::ExprChild(tp::String id) {
|
|||
return new ExpressionChild(this, id);
|
||||
}
|
||||
|
||||
ExpressionCall* Expression::ExprCall(tp::init_list<Expression*> args) {
|
||||
ExpressionCall* Expression::ExprCall(tp::InitialierList<Expression*> args) {
|
||||
return new ExpressionCall(this, args);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ ExpressionBoolean::ExpressionBoolean(Expression* invert)
|
|||
: Expression(Type::BOOLEAN), mLeft(invert), mBoolType(BoolType::NOT){
|
||||
}
|
||||
|
||||
ExpressionCall::ExpressionCall(Expression * mParent, tp::init_list<Expression*> args) : Expression(Type::CALL), mParent(mParent) {
|
||||
ExpressionCall::ExpressionCall(Expression * mParent, tp::InitialierList<Expression*> args) : Expression(Type::CALL), mParent(mParent) {
|
||||
mArgs = args;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ void FunctionDefinition::EvalStatement(Statement* stm) {
|
|||
auto jump_inst = inst(Instruction(NULL, Instruction::InstType::JUMP));
|
||||
auto end_mark = inst(Instruction());
|
||||
|
||||
jump_if_inst->data.mInstTarget = end_mark;
|
||||
jump_inst->data.mInstTarget = check_mark;
|
||||
jump_if_inst->data.mInstTarget = &end_mark->data;
|
||||
jump_inst->data.mInstTarget = &check_mark->data;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -98,8 +98,8 @@ void FunctionDefinition::EvalStatement(Statement* stm) {
|
|||
|
||||
auto end_mark = inst(Instruction());
|
||||
|
||||
jump_if_inst->data.mInstTarget = else_mark;
|
||||
jump_inst->data.mInstTarget = end_mark;
|
||||
jump_if_inst->data.mInstTarget = &else_mark->data;
|
||||
jump_inst->data.mInstTarget = &end_mark->data;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -396,11 +396,11 @@ void writeParam(ByteCode& out, tp::alni& idx, tp::int1* data, tp::alni size) {
|
|||
}
|
||||
}
|
||||
|
||||
tp::alni calcOffset(tp::List<Instruction>::Node* jump_inst, tp::List<Instruction>::Node* to) {
|
||||
tp::alni calcOffset(tp::List<Instruction>::Node* jump_inst, Instruction* to) {
|
||||
tp::alni offset = 0;
|
||||
bool reversed = jump_inst->data.mInstIdx > to->data.mInstIdx;
|
||||
bool reversed = jump_inst->data.mInstIdx > to->mInstIdx;
|
||||
auto iter_node = reversed ? jump_inst : jump_inst->next;
|
||||
while (iter_node != to) {
|
||||
while (&iter_node->data != to) {
|
||||
offset += instSize(iter_node->data);
|
||||
iter_node = reversed ? iter_node->prev : iter_node->next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "compiler/instruction.h"
|
||||
|
||||
using namespace obj;
|
||||
|
|
@ -24,6 +25,6 @@ Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes)
|
|||
: mOp(op), mParam(param), mArgType(ArgType::PARAM), mParamBytes(nBytes), mInstType(InstType::EXEC) {
|
||||
}
|
||||
|
||||
Instruction::Instruction(tp::List<Instruction>::Node* inst, InstType jump_type): mInstTarget(inst) {
|
||||
Instruction::Instruction(Instruction* inst, InstType jump_type): mInstTarget(inst) {
|
||||
mInstType = jump_type;
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ using namespace obj;
|
|||
using namespace BCgen;
|
||||
|
||||
|
||||
StatementFuncDef::StatementFuncDef(tp::String function_id, tp::init_list<tp::String> args, tp::init_list<Statement*> statements) {
|
||||
StatementFuncDef::StatementFuncDef(tp::String function_id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> statements) {
|
||||
mType = Type::DEF_FUNC;
|
||||
mArgs = args;
|
||||
mStatements = statements;
|
||||
|
|
@ -36,7 +36,7 @@ StatementPrint::StatementPrint(Expression* target) : mTarget(target) {
|
|||
mType = Type::PRINT;
|
||||
}
|
||||
|
||||
StatementScope::StatementScope(tp::init_list<Statement*> statements, bool aPushToScopeStack) {
|
||||
StatementScope::StatementScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack) {
|
||||
mType = Type::SCOPE;
|
||||
mStatements = statements;
|
||||
mPushToScopeStack = aPushToScopeStack;
|
||||
|
|
@ -67,7 +67,7 @@ StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope)
|
|||
}
|
||||
// helpers
|
||||
|
||||
StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::init_list<tp::String> args, tp::init_list<Statement*> stms) {
|
||||
StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> stms) {
|
||||
return new StatementFuncDef(id, args, stms);
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ StatementIf* obj::BCgen::StmIf(Expression* condition, StatementScope* on_true, S
|
|||
return new StatementIf(condition, on_true, on_false);
|
||||
}
|
||||
|
||||
StatementScope* obj::BCgen::StmScope(tp::init_list<Statement*> statements, bool aPushToScopeStack = false) {
|
||||
StatementScope* obj::BCgen::StmScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack = false) {
|
||||
return new StatementScope(statements, aPushToScopeStack);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue