Adding support for windows and fixing some errors

This commit is contained in:
Ilusha 2024-01-15 16:35:16 -08:00 committed by IlyaShurupov
parent 2722a25036
commit 34a8d4eafd
84 changed files with 168 additions and 255 deletions

View file

@ -1,5 +1,4 @@
#include "compiler/constants.h"
#include "NewPlacement.hpp"
#include "primitives/methodobject.h"
#include "primitives/primitives.h"
@ -142,4 +141,4 @@ void ConstObjectsPool::save(tp::Buffer<ConstData>& out) {
mBoolTrue.mConstIdx = data_idx;
}
mDelete = false;
}
}

View file

@ -1,5 +1,4 @@
#include "compiler/expression.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace BCgen;
@ -64,30 +63,30 @@ ExpressionFunc::ExpressionFunc(tp::String id) :
Expression(Type::FUNC),
mFuncId(id) {}
ExpressionConst::ExpressionConst(tp::String val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(STR),
str(val) {}
ExpressionConst::ExpressionConst(const char* val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(STR),
str(val) {}
ExpressionConst::ExpressionConst(tp::int4 val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(INT),
integer(val) {}
ExpressionConst::ExpressionConst(tp::flt4 val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(FLT),
floating(val) {}
ExpressionConst::ExpressionConst(tp::alni val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(INT),
integer(val) {}
ExpressionConst::ExpressionConst(tp::alnf val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(FLT),
floating(val) {}
ExpressionConst::ExpressionConst(bool val) :
Expression(Type::CONST),
Expression(Type::CONST_EXPR),
mConstType(BOOL),
boolean(val) {}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "compiler/function.h"
#include "primitives/methodobject.h"
@ -305,7 +303,7 @@ void FunctionDefinition::EvalExpr(Expression* expr) {
inst(Instruction(OpCode::LOAD_LOCAL, mConstants.get(local->mLocalId)));
break;
}
case Expression::Type::CONST:
case Expression::Type::CONST_EXPR:
{
auto constobj = (ExpressionConst*) expr;
switch (constobj->mConstType) {
@ -384,7 +382,7 @@ tp::alni instSize(const Instruction& inst) {
out += inst.mParamBytes;
return out;
}
case Instruction::ArgType::CONST:
case Instruction::ArgType::CONST_ARG:
{
out += 2;
if (inst.mConstData2) {
@ -516,7 +514,7 @@ void FunctionDefinition::generateByteCode(ByteCode& out) {
writeParam(out, idx, (tp::int1*) &inst.mParam, inst.mParamBytes);
break;
}
case Instruction::ArgType::CONST:
case Instruction::ArgType::CONST_ARG:
{
writeConst(out, idx, (tp::uint2) inst.mConstData->mConstIdx);
if (inst.mConstData2) {
@ -594,4 +592,4 @@ bool obj::BCgen::Compile(obj::MethodObject* method) {
delete res.scope;
return true;
}
}

View file

@ -1,6 +1,5 @@
#include "compiler/instruction.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace tp;
@ -21,14 +20,14 @@ Instruction::Instruction(ConstObject* constData) :
Instruction::Instruction(OpCode op, ConstObject* constData) :
mOp(op),
mConstData(constData),
mArgType(ArgType::CONST),
mArgType(ArgType::CONST_ARG),
mInstType(InstType::EXEC) {}
Instruction::Instruction(OpCode op, ConstObject* constData, ConstObject* constData2) :
mOp(op),
mConstData(constData),
mConstData2(constData2),
mArgType(ArgType::CONST),
mArgType(ArgType::CONST_ARG),
mInstType(InstType::EXEC) {}
Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) :
@ -41,4 +40,4 @@ Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) :
Instruction::Instruction(Instruction* inst, InstType jump_type) :
mInstTarget(inst) {
mInstType = jump_type;
}
}

View file

@ -1,5 +1,4 @@
#include "compiler/statement.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace BCgen;
@ -76,7 +75,7 @@ StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope)
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) {
if (value->mType == Expression::Type::CONST_EXPR) {
return new StatementLocalDef(id, (ExpressionConst*) value);
}
@ -99,4 +98,4 @@ StatementWhile* obj::BCgen::StmWhile(Expression* condition, StatementScope* scop
StatementIgnore* obj::BCgen::StmIgnore(Expression* expr) { return new StatementIgnore(expr); }
StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) { return new StatementClassDef(id, scope); }
StatementClassDef* obj::BCgen::StmClassDef(tp::String id, StatementScope* scope) { return new StatementClassDef(id, scope); }