Apply formating to all files. CLeanup
This commit is contained in:
parent
43e374f269
commit
744c01c5d0
928 changed files with 14515 additions and 21480 deletions
|
|
@ -1,148 +1,145 @@
|
|||
#include "NewPlacement.hpp"
|
||||
#include "compiler/constants.h"
|
||||
#include "primitives/primitives.h"
|
||||
#include "primitives/methodobject.h"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
using namespace BCgen;
|
||||
|
||||
ConstObject::ConstObject() {}
|
||||
ConstObject::ConstObject(obj::Object* mObj) : mObj(mObj) {}
|
||||
|
||||
ConstObjectsPool::~ConstObjectsPool() {
|
||||
if (mDelete) {
|
||||
for (auto obj : mStrings) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mMethods) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
if (mBoolFalse.mObj) {
|
||||
obj::NDO->destroy(mBoolFalse.mObj);
|
||||
}
|
||||
if (mBoolTrue.mObj) {
|
||||
obj::NDO->destroy(mBoolTrue.mObj);
|
||||
}
|
||||
}
|
||||
for (auto obj : mStrings) {
|
||||
delete obj->val;
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
delete obj->val;
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
delete obj->val;
|
||||
}
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::registerObject(obj::Object* obj) {
|
||||
ConstObject* out = new ConstObject(obj);
|
||||
mTotalObjects++;
|
||||
return out;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::alni val) {
|
||||
auto idx = mIntegers.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mIntegers.getSlotVal(idx);
|
||||
}
|
||||
else {
|
||||
const_obj = registerObject(IntObject::create(val));
|
||||
mIntegers.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::String val) {
|
||||
auto idx = mStrings.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mStrings.getSlotVal(idx);
|
||||
}
|
||||
else {
|
||||
const_obj = registerObject(StringObject::create(val));
|
||||
mStrings.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::alnf val) {
|
||||
auto idx = mFloats.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mFloats.getSlotVal(idx);
|
||||
}
|
||||
else {
|
||||
const_obj = registerObject(FloatObject::create(val));
|
||||
mFloats.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(bool val) {
|
||||
if (val) {
|
||||
if (!mBoolTrue.mObj) {
|
||||
mBoolTrue.mObj = BoolObject::create(val);
|
||||
mTotalObjects++;
|
||||
}
|
||||
return &mBoolTrue;
|
||||
}
|
||||
else {
|
||||
if (!mBoolFalse.mObj) {
|
||||
mBoolFalse.mObj = BoolObject::create(val);
|
||||
mTotalObjects++;
|
||||
}
|
||||
return &mBoolFalse;
|
||||
}
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::addMethod(tp::String method_id, obj::Object* method) {
|
||||
ASSERT(NDO_CAST(MethodObject, method) && "Object is not a method object");
|
||||
ASSERT(!mMethods.presents(method_id) && "Method Redefinition");
|
||||
auto out = registerObject(method);
|
||||
mMethods.put(method_id, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void ConstObjectsPool::save(tp::Buffer<ConstData>& out) {
|
||||
out.reserve(mTotalObjects);
|
||||
tp::alni data_idx = 0;
|
||||
for (auto obj : mMethods) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mStrings) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
if (mBoolFalse.mObj) {
|
||||
out[data_idx] = mBoolFalse.mObj;
|
||||
mBoolFalse.mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
if (mBoolTrue.mObj) {
|
||||
out[data_idx] = mBoolTrue.mObj;
|
||||
mBoolTrue.mConstIdx = data_idx;
|
||||
}
|
||||
mDelete = false;
|
||||
#include "compiler/constants.h"
|
||||
#include "NewPlacement.hpp"
|
||||
#include "primitives/methodobject.h"
|
||||
#include "primitives/primitives.h"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
using namespace BCgen;
|
||||
|
||||
ConstObject::ConstObject() {}
|
||||
ConstObject::ConstObject(obj::Object* mObj) :
|
||||
mObj(mObj) {}
|
||||
|
||||
ConstObjectsPool::~ConstObjectsPool() {
|
||||
if (mDelete) {
|
||||
for (auto obj : mStrings) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mMethods) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
}
|
||||
if (mBoolFalse.mObj) {
|
||||
obj::NDO->destroy(mBoolFalse.mObj);
|
||||
}
|
||||
if (mBoolTrue.mObj) {
|
||||
obj::NDO->destroy(mBoolTrue.mObj);
|
||||
}
|
||||
}
|
||||
for (auto obj : mStrings) {
|
||||
delete obj->val;
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
delete obj->val;
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
delete obj->val;
|
||||
}
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::registerObject(obj::Object* obj) {
|
||||
ConstObject* out = new ConstObject(obj);
|
||||
mTotalObjects++;
|
||||
return out;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::alni val) {
|
||||
auto idx = mIntegers.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mIntegers.getSlotVal(idx);
|
||||
} else {
|
||||
const_obj = registerObject(IntObject::create(val));
|
||||
mIntegers.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::String val) {
|
||||
auto idx = mStrings.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mStrings.getSlotVal(idx);
|
||||
} else {
|
||||
const_obj = registerObject(StringObject::create(val));
|
||||
mStrings.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(tp::alnf val) {
|
||||
auto idx = mFloats.presents(val);
|
||||
ConstObject* const_obj = NULL;
|
||||
if (idx) {
|
||||
const_obj = mFloats.getSlotVal(idx);
|
||||
} else {
|
||||
const_obj = registerObject(FloatObject::create(val));
|
||||
mFloats.put(val, const_obj);
|
||||
}
|
||||
return const_obj;
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::get(bool val) {
|
||||
if (val) {
|
||||
if (!mBoolTrue.mObj) {
|
||||
mBoolTrue.mObj = BoolObject::create(val);
|
||||
mTotalObjects++;
|
||||
}
|
||||
return &mBoolTrue;
|
||||
} else {
|
||||
if (!mBoolFalse.mObj) {
|
||||
mBoolFalse.mObj = BoolObject::create(val);
|
||||
mTotalObjects++;
|
||||
}
|
||||
return &mBoolFalse;
|
||||
}
|
||||
}
|
||||
|
||||
ConstObject* ConstObjectsPool::addMethod(tp::String method_id, obj::Object* method) {
|
||||
ASSERT(NDO_CAST(MethodObject, method) && "Object is not a method object");
|
||||
ASSERT(!mMethods.presents(method_id) && "Method Redefinition");
|
||||
auto out = registerObject(method);
|
||||
mMethods.put(method_id, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void ConstObjectsPool::save(tp::Buffer<ConstData>& out) {
|
||||
out.reserve(mTotalObjects);
|
||||
tp::alni data_idx = 0;
|
||||
for (auto obj : mMethods) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mStrings) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
out[data_idx] = obj->val->mObj;
|
||||
obj->val->mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
if (mBoolFalse.mObj) {
|
||||
out[data_idx] = mBoolFalse.mObj;
|
||||
mBoolFalse.mConstIdx = data_idx;
|
||||
data_idx++;
|
||||
}
|
||||
if (mBoolTrue.mObj) {
|
||||
out[data_idx] = mBoolTrue.mObj;
|
||||
mBoolTrue.mConstIdx = data_idx;
|
||||
}
|
||||
mDelete = false;
|
||||
}
|
||||
|
|
@ -1,70 +1,93 @@
|
|||
#include "NewPlacement.hpp"
|
||||
#include "compiler/expression.h"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
||||
Expression::Expression() {}
|
||||
Expression::Expression(Type type) : mType(type) {}
|
||||
|
||||
ExpressionChild* Expression::ExprChild(tp::String id) {
|
||||
return new ExpressionChild(this, id);
|
||||
}
|
||||
|
||||
ExpressionCall* Expression::ExprCall(tp::InitialierList<Expression*> args) {
|
||||
return new ExpressionCall(this, args);
|
||||
}
|
||||
|
||||
ExpressionLocal* obj::BCgen::ExprLocal(tp::String id) {
|
||||
return new ExpressionLocal(id);
|
||||
}
|
||||
|
||||
ExpressionSelf* obj::BCgen::ExprSelf() {
|
||||
return new ExpressionSelf();
|
||||
}
|
||||
|
||||
ExpressionNew* obj::BCgen::ExprNew(tp::String type) {
|
||||
return new ExpressionNew(type);
|
||||
}
|
||||
|
||||
ExpressionAriphm* obj::BCgen::ExprAriphm(Expression* left, Expression* right, OpCode type) {
|
||||
return new ExpressionAriphm(left, right, type);
|
||||
}
|
||||
|
||||
ExpressionFunc* obj::BCgen::ExprFunc(tp::String id) {
|
||||
return new ExpressionFunc(id);
|
||||
}
|
||||
|
||||
ExpressionBoolean* obj::BCgen::ExprBool(Expression* left, Expression* right, obj::OpCode type) {
|
||||
return new ExpressionBoolean(left, right, ExpressionBoolean::BoolType(type));
|
||||
}
|
||||
|
||||
ExpressionBoolean* obj::BCgen::ExprBoolNot(Expression* invert) {
|
||||
return new ExpressionBoolean(invert);
|
||||
}
|
||||
|
||||
ExpressionBoolean::ExpressionBoolean(Expression* left, Expression* right, BoolType type)
|
||||
: Expression(Type::BOOLEAN), mLeft(left), mRight(right), mBoolType(type) {
|
||||
}
|
||||
|
||||
ExpressionBoolean::ExpressionBoolean(Expression* invert)
|
||||
: Expression(Type::BOOLEAN), mLeft(invert), mBoolType(BoolType::NOT){
|
||||
}
|
||||
|
||||
ExpressionCall::ExpressionCall(Expression * mParent, tp::InitialierList<Expression*> args) : Expression(Type::CALL), mParent(mParent) {
|
||||
mArgs = args;
|
||||
}
|
||||
|
||||
ExpressionNew::ExpressionNew(tp::String type) : Expression(Type::NEW), mNewType(type) {}
|
||||
ExpressionLocal::ExpressionLocal(tp::String id) : Expression(Type::LOCAL), mLocalId(id) {}
|
||||
ExpressionSelf::ExpressionSelf() : Expression(Type::SELF) {}
|
||||
ExpressionChild::ExpressionChild(Expression* mParent, tp::String id) : Expression(Type::CHILD), mParent(mParent), mLocalId(id) {}
|
||||
ExpressionAriphm::ExpressionAriphm(Expression* left, Expression* right, OpCode type) : Expression(Type::ARIPHM), mLeft(left), mRight(right), mOpType(type) {}
|
||||
ExpressionFunc::ExpressionFunc(tp::String id) : Expression(Type::FUNC), mFuncId(id) {}
|
||||
ExpressionConst::ExpressionConst(tp::String val) : Expression(Type::CONST), mConstType(STR), str(val) {}
|
||||
ExpressionConst::ExpressionConst(const char* val) : Expression(Type::CONST), mConstType(STR), str(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::int4 val) : Expression(Type::CONST), mConstType(INT), integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::flt4 val) : Expression(Type::CONST), mConstType(FLT), floating(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alni val) : Expression(Type::CONST), mConstType(INT), integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alnf val) : Expression(Type::CONST), mConstType(FLT), floating(val) {}
|
||||
ExpressionConst::ExpressionConst(bool val) : Expression(Type::CONST), mConstType(BOOL), boolean(val) {}
|
||||
#include "compiler/expression.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
||||
Expression::Expression() {}
|
||||
Expression::Expression(Type type) :
|
||||
mType(type) {}
|
||||
|
||||
ExpressionChild* Expression::ExprChild(tp::String id) { return new ExpressionChild(this, id); }
|
||||
|
||||
ExpressionCall* Expression::ExprCall(tp::InitialierList<Expression*> args) { return new ExpressionCall(this, args); }
|
||||
|
||||
ExpressionLocal* obj::BCgen::ExprLocal(tp::String id) { return new ExpressionLocal(id); }
|
||||
|
||||
ExpressionSelf* obj::BCgen::ExprSelf() { return new ExpressionSelf(); }
|
||||
|
||||
ExpressionNew* obj::BCgen::ExprNew(tp::String type) { return new ExpressionNew(type); }
|
||||
|
||||
ExpressionAriphm* obj::BCgen::ExprAriphm(Expression* left, Expression* right, OpCode type) { return new ExpressionAriphm(left, right, type); }
|
||||
|
||||
ExpressionFunc* obj::BCgen::ExprFunc(tp::String id) { return new ExpressionFunc(id); }
|
||||
|
||||
ExpressionBoolean* obj::BCgen::ExprBool(Expression* left, Expression* right, obj::OpCode type) { return new ExpressionBoolean(left, right, ExpressionBoolean::BoolType(type)); }
|
||||
|
||||
ExpressionBoolean* obj::BCgen::ExprBoolNot(Expression* invert) { return new ExpressionBoolean(invert); }
|
||||
|
||||
ExpressionBoolean::ExpressionBoolean(Expression* left, Expression* right, BoolType type) :
|
||||
Expression(Type::BOOLEAN),
|
||||
mLeft(left),
|
||||
mRight(right),
|
||||
mBoolType(type) {}
|
||||
|
||||
ExpressionBoolean::ExpressionBoolean(Expression* invert) :
|
||||
Expression(Type::BOOLEAN),
|
||||
mLeft(invert),
|
||||
mBoolType(BoolType::NOT) {}
|
||||
|
||||
ExpressionCall::ExpressionCall(Expression* mParent, tp::InitialierList<Expression*> args) :
|
||||
Expression(Type::CALL),
|
||||
mParent(mParent) {
|
||||
mArgs = args;
|
||||
}
|
||||
|
||||
ExpressionNew::ExpressionNew(tp::String type) :
|
||||
Expression(Type::NEW),
|
||||
mNewType(type) {}
|
||||
ExpressionLocal::ExpressionLocal(tp::String id) :
|
||||
Expression(Type::LOCAL),
|
||||
mLocalId(id) {}
|
||||
ExpressionSelf::ExpressionSelf() :
|
||||
Expression(Type::SELF) {}
|
||||
ExpressionChild::ExpressionChild(Expression* mParent, tp::String id) :
|
||||
Expression(Type::CHILD),
|
||||
mParent(mParent),
|
||||
mLocalId(id) {}
|
||||
ExpressionAriphm::ExpressionAriphm(Expression* left, Expression* right, OpCode type) :
|
||||
Expression(Type::ARIPHM),
|
||||
mLeft(left),
|
||||
mRight(right),
|
||||
mOpType(type) {}
|
||||
ExpressionFunc::ExpressionFunc(tp::String id) :
|
||||
Expression(Type::FUNC),
|
||||
mFuncId(id) {}
|
||||
ExpressionConst::ExpressionConst(tp::String val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(STR),
|
||||
str(val) {}
|
||||
ExpressionConst::ExpressionConst(const char* val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(STR),
|
||||
str(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::int4 val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(INT),
|
||||
integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::flt4 val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(FLT),
|
||||
floating(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alni val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(INT),
|
||||
integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alnf val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(FLT),
|
||||
floating(val) {}
|
||||
ExpressionConst::ExpressionConst(bool val) :
|
||||
Expression(Type::CONST),
|
||||
mConstType(BOOL),
|
||||
boolean(val) {}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,30 +1,44 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "compiler/instruction.h"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
using namespace BCgen;
|
||||
|
||||
Instruction::Instruction(OpCode op) : mOp(op), mArgType(ArgType::NO_ARG), mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction() : mInstType(InstType::NONE) {}
|
||||
|
||||
Instruction::Instruction(ConstObject* constData)
|
||||
: mConstData(constData), mInstType(InstType::PURE_CONST) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, ConstObject* constData)
|
||||
: mOp(op), mConstData(constData), mArgType(ArgType::CONST), mInstType(InstType::EXEC) {
|
||||
}
|
||||
|
||||
Instruction::Instruction(OpCode op, ConstObject* constData, ConstObject* constData2)
|
||||
: mOp(op), mConstData(constData), mConstData2(constData2), mArgType(ArgType::CONST), mInstType(InstType::EXEC) {
|
||||
}
|
||||
|
||||
Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes)
|
||||
: mOp(op), mParam(param), mArgType(ArgType::PARAM), mParamBytes(nBytes), mInstType(InstType::EXEC) {
|
||||
}
|
||||
|
||||
Instruction::Instruction(Instruction* inst, InstType jump_type): mInstTarget(inst) {
|
||||
mInstType = jump_type;
|
||||
|
||||
#include "compiler/instruction.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
using namespace BCgen;
|
||||
|
||||
Instruction::Instruction(OpCode op) :
|
||||
mOp(op),
|
||||
mArgType(ArgType::NO_ARG),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction() :
|
||||
mInstType(InstType::NONE) {}
|
||||
|
||||
Instruction::Instruction(ConstObject* constData) :
|
||||
mConstData(constData),
|
||||
mInstType(InstType::PURE_CONST) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, ConstObject* constData) :
|
||||
mOp(op),
|
||||
mConstData(constData),
|
||||
mArgType(ArgType::CONST),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, ConstObject* constData, ConstObject* constData2) :
|
||||
mOp(op),
|
||||
mConstData(constData),
|
||||
mConstData2(constData2),
|
||||
mArgType(ArgType::CONST),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) :
|
||||
mOp(op),
|
||||
mParam(param),
|
||||
mArgType(ArgType::PARAM),
|
||||
mParamBytes(nBytes),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction(Instruction* inst, InstType jump_type) :
|
||||
mInstTarget(inst) {
|
||||
mInstType = jump_type;
|
||||
}
|
||||
|
|
@ -1,116 +1,102 @@
|
|||
#include "NewPlacement.hpp"
|
||||
#include "compiler/statement.h"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
||||
|
||||
StatementFuncDef::StatementFuncDef(tp::String function_id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> statements) {
|
||||
mType = Type::DEF_FUNC;
|
||||
mArgs = args;
|
||||
mStatements = statements;
|
||||
mFunctionId = function_id;
|
||||
}
|
||||
|
||||
StatementLocalDef::StatementLocalDef(tp::String id, Expression* value) : mLocalId(id), mNewExpr(value) {
|
||||
mType = Type::DEF_LOCAL;
|
||||
}
|
||||
|
||||
StatementLocalDef::StatementLocalDef(tp::String id, ExpressionConst* value) : mLocalId(id), mConstExpr(value), mIsConstExpr(true) {
|
||||
mType = Type::DEF_LOCAL;
|
||||
}
|
||||
|
||||
StatementCopy::StatementCopy(Expression* left, Expression* right) : mLeft(left), mRight(right) {
|
||||
mType = Type::COPY;
|
||||
}
|
||||
|
||||
StatementReturn::StatementReturn() {
|
||||
mType = Type::RET;
|
||||
}
|
||||
|
||||
StatementReturn::StatementReturn(Expression* ret) : mRet(ret) {
|
||||
mType = Type::RET;
|
||||
}
|
||||
|
||||
StatementPrint::StatementPrint(Expression* target) : mTarget(target) {
|
||||
mType = Type::PRINT;
|
||||
}
|
||||
|
||||
StatementScope::StatementScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack) {
|
||||
mType = Type::SCOPE;
|
||||
mStatements = statements;
|
||||
mPushToScopeStack = aPushToScopeStack;
|
||||
}
|
||||
|
||||
StatementIf::StatementIf(Expression* condition, StatementScope* on_true, StatementScope* on_false) {
|
||||
mType = Type::IF;
|
||||
mOnFalse = on_false;
|
||||
mOnTrue = on_true;
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
StatementWhile::StatementWhile(Expression* condition, StatementScope* scope) {
|
||||
mType = Type::WHILE;
|
||||
mScope = scope;
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
StatementIgnore::StatementIgnore(Expression* expr) {
|
||||
mType = Type::IGNORE;
|
||||
mExpr = expr;
|
||||
}
|
||||
|
||||
StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope) {
|
||||
mClassId = class_id;
|
||||
mScope = scope;
|
||||
mType = Type::CLASS_DEF;
|
||||
}
|
||||
// helpers
|
||||
|
||||
StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> stms) {
|
||||
return new StatementFuncDef(id, args, stms);
|
||||
}
|
||||
|
||||
StatementLocalDef* obj::BCgen::StmDefLocal(tp::String id, Expression* value) {
|
||||
if (value->mType == Expression::Type::CONST) {
|
||||
return new StatementLocalDef(id, (ExpressionConst*)value);
|
||||
}
|
||||
|
||||
return new StatementLocalDef(id, value);
|
||||
}
|
||||
|
||||
StatementCopy* obj::BCgen::StmCopy(Expression* left, Expression* right) {
|
||||
return new StatementCopy(left, right);
|
||||
}
|
||||
|
||||
StatementPrint* obj::BCgen::StmPrint(Expression* target) {
|
||||
return new StatementPrint(target);
|
||||
}
|
||||
|
||||
StatementReturn* obj::BCgen::StmReturn() {
|
||||
return new StatementReturn();
|
||||
}
|
||||
|
||||
StatementReturn* obj::BCgen::StmReturn(Expression* obj) {
|
||||
return new StatementReturn(obj);
|
||||
}
|
||||
|
||||
StatementIf* obj::BCgen::StmIf(Expression* condition, StatementScope* on_true, StatementScope* on_false) {
|
||||
return new StatementIf(condition, on_true, on_false);
|
||||
}
|
||||
|
||||
StatementScope* obj::BCgen::StmScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack = false) {
|
||||
return new StatementScope(statements, aPushToScopeStack);
|
||||
}
|
||||
|
||||
StatementWhile* obj::BCgen::StmWhile(Expression* condition, StatementScope* scope) {
|
||||
return new StatementWhile(condition, scope);
|
||||
}
|
||||
|
||||
StatementIgnore* obj::BCgen::StmIgnore(Expression* expr) {
|
||||
return new StatementIgnore(expr);
|
||||
}
|
||||
|
||||
StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) {
|
||||
return new StatementClassDef(id, scope);
|
||||
}
|
||||
#include "compiler/statement.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
||||
StatementFuncDef::StatementFuncDef(tp::String function_id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> statements) {
|
||||
mType = Type::DEF_FUNC;
|
||||
mArgs = args;
|
||||
mStatements = statements;
|
||||
mFunctionId = function_id;
|
||||
}
|
||||
|
||||
StatementLocalDef::StatementLocalDef(tp::String id, Expression* value) :
|
||||
mLocalId(id),
|
||||
mNewExpr(value) {
|
||||
mType = Type::DEF_LOCAL;
|
||||
}
|
||||
|
||||
StatementLocalDef::StatementLocalDef(tp::String id, ExpressionConst* value) :
|
||||
mLocalId(id),
|
||||
mConstExpr(value),
|
||||
mIsConstExpr(true) {
|
||||
mType = Type::DEF_LOCAL;
|
||||
}
|
||||
|
||||
StatementCopy::StatementCopy(Expression* left, Expression* right) :
|
||||
mLeft(left),
|
||||
mRight(right) {
|
||||
mType = Type::COPY;
|
||||
}
|
||||
|
||||
StatementReturn::StatementReturn() { mType = Type::RET; }
|
||||
|
||||
StatementReturn::StatementReturn(Expression* ret) :
|
||||
mRet(ret) {
|
||||
mType = Type::RET;
|
||||
}
|
||||
|
||||
StatementPrint::StatementPrint(Expression* target) :
|
||||
mTarget(target) {
|
||||
mType = Type::PRINT;
|
||||
}
|
||||
|
||||
StatementScope::StatementScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack) {
|
||||
mType = Type::SCOPE;
|
||||
mStatements = statements;
|
||||
mPushToScopeStack = aPushToScopeStack;
|
||||
}
|
||||
|
||||
StatementIf::StatementIf(Expression* condition, StatementScope* on_true, StatementScope* on_false) {
|
||||
mType = Type::IF;
|
||||
mOnFalse = on_false;
|
||||
mOnTrue = on_true;
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
StatementWhile::StatementWhile(Expression* condition, StatementScope* scope) {
|
||||
mType = Type::WHILE;
|
||||
mScope = scope;
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
StatementIgnore::StatementIgnore(Expression* expr) {
|
||||
mType = Type::IGNORE;
|
||||
mExpr = expr;
|
||||
}
|
||||
|
||||
StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope) {
|
||||
mClassId = class_id;
|
||||
mScope = scope;
|
||||
mType = Type::CLASS_DEF;
|
||||
}
|
||||
// helpers
|
||||
|
||||
StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> stms) { return new StatementFuncDef(id, args, stms); }
|
||||
|
||||
StatementLocalDef* obj::BCgen::StmDefLocal(tp::String id, Expression* value) {
|
||||
if (value->mType == Expression::Type::CONST) {
|
||||
return new StatementLocalDef(id, (ExpressionConst*) value);
|
||||
}
|
||||
|
||||
return new StatementLocalDef(id, value);
|
||||
}
|
||||
|
||||
StatementCopy* obj::BCgen::StmCopy(Expression* left, Expression* right) { return new StatementCopy(left, right); }
|
||||
|
||||
StatementPrint* obj::BCgen::StmPrint(Expression* target) { return new StatementPrint(target); }
|
||||
|
||||
StatementReturn* obj::BCgen::StmReturn() { return new StatementReturn(); }
|
||||
|
||||
StatementReturn* obj::BCgen::StmReturn(Expression* obj) { return new StatementReturn(obj); }
|
||||
|
||||
StatementIf* obj::BCgen::StmIf(Expression* condition, StatementScope* on_true, StatementScope* on_false) { return new StatementIf(condition, on_true, on_false); }
|
||||
|
||||
StatementScope* obj::BCgen::StmScope(tp::InitialierList<Statement*> statements, bool aPushToScopeStack = false) { return new StatementScope(statements, aPushToScopeStack); }
|
||||
|
||||
StatementWhile* obj::BCgen::StmWhile(Expression* condition, StatementScope* scope) { return new StatementWhile(condition, scope); }
|
||||
|
||||
StatementIgnore* obj::BCgen::StmIgnore(Expression* expr) { return new StatementIgnore(expr); }
|
||||
|
||||
StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) { return new StatementClassDef(id, scope); }
|
||||
Loading…
Add table
Add a link
Reference in a new issue