Adding support for windows and fixing some errors

This commit is contained in:
Ilusha 2024-01-15 16:35:16 -08:00 committed by Ilya Shurupov
parent 7660d58f26
commit 420bb37039
84 changed files with 168 additions and 255 deletions

View file

@ -6,7 +6,7 @@
#include "compiler/function.h"
#include "strings.h"
#include "Strings.hpp"
namespace obj {

View file

@ -1,5 +1,4 @@
#include "NewPlacement.hpp"
#include "Window.hpp"
#include "GUI.h"
@ -45,4 +44,4 @@ int main() {
}
return 0;
}
}

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); }

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "Tokenizer.hpp"
#include "compiler/function.h"
@ -88,4 +86,4 @@ static tp::ModuleManifest* sModuleDependencies[] = {
NULL
};
tp::ModuleManifest obj::gModuleObjects = tp::ModuleManifest("Objects", init, deinit, sModuleDependencies);
tp::ModuleManifest obj::gModuleObjects = tp::ModuleManifest("Objects", init, deinit, sModuleDependencies);

View file

@ -1,7 +1,5 @@
#include "NewPlacement.hpp"
#include "core/object.h"
#include "primitives/classobject.h"
@ -224,4 +222,4 @@ namespace obj {
}
return NULL;
}
};
};

View file

@ -1,6 +1,5 @@
#include "NewPlacement.hpp"
#include "core/object.h"
#include "primitives/nullobject.h"
@ -432,4 +431,4 @@ namespace obj {
sl_callbacks[sl_callbacks_load_idx] = in;
sl_callbacks_load_idx++;
}
};
};

View file

@ -1,6 +1,5 @@
#include "HeapAllocatorGlobal.hpp"
#include "NewPlacement.hpp"
#include "core/scriptsection.h"

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "core/typegroups.h"
#include "core/object.h"
@ -80,4 +78,4 @@ obj::TypeGroups::~TypeGroups() {
}
childs.~Map();
}
}
}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "core/typemethods.h"
#include "primitives/floatobject.h"
@ -131,4 +129,4 @@ void TypeMethod::init() {
while (args[mNargs].descr) {
mNargs++;
}
}
}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "interpreter/callstack.h"
#include "interpreter/bytecode.h"
@ -33,4 +31,4 @@ void CallStack::leave() {
ByteCode* CallStack::getBytecode() { return &mStack.last().mMethod->mScript->mBytecode; }
tp::halni CallStack::len() const { return mStack.size(); }
tp::halni CallStack::len() const { return mStack.size(); }

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "interpreter/interpreter.h"
#include "primitives/primitives.h"
@ -606,4 +604,4 @@ void Interpreter::execAll(obj::MethodObject* method, obj::ClassObject* self, obj
while (!finished()) {
stepBytecodeIn();
}
}
}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "interpreter/operandsstack.h"
using namespace obj;

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "interpreter/scopestack.h"
using namespace obj;

View file

@ -1,7 +1,6 @@
#include "primitives/boolobject.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace tp;
@ -53,4 +52,4 @@ struct obj::ObjectType obj::BoolObject::TypeData = {
.save_size = (object_save_size) save_size,
.save = (object_save) save,
.load = (object_load) load,
};
};

View file

@ -1,6 +1,3 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/classobject.h"
#include "primitives/dictobject.h"

View file

@ -1,6 +1,5 @@
#include "primitives/colorobject.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace tp;
@ -63,4 +62,4 @@ struct obj::ObjectType obj::ColorObject::TypeData = {
.save_size = (object_save_size) save_size,
.save = (object_save) save,
.load = (object_load) load,
};
};

View file

@ -1,6 +1,3 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/dictobject.h"
#include "primitives/stringobject.h"

View file

@ -1,8 +1,5 @@
#pragma once
#include "primitives/enumobject.h"
#include "NewPlacement.hpp"
#include <malloc.h>
@ -174,4 +171,4 @@ struct obj::ObjectType obj::EnumObject::TypeData = {
.load = (object_load) load,
.comparison = (object_compare) EnumObject::compare,
.allocated_size = (object_allocated_size) allocated_size,
};
};

View file

@ -1,7 +1,4 @@
#pragma once
#include "primitives/floatobject.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace tp;
@ -69,4 +66,4 @@ struct obj::ObjectType obj::FloatObject::TypeData = {
.save_size = (object_save_size) save_size,
.save = (object_save) save,
.load = (object_load) load,
};
};

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "primitives/interpreterobject.h"
#include "primitives/linkobject.h"
#include "primitives/methodobject.h"
@ -75,4 +73,4 @@ struct obj::ObjectType InterpreterObject::TypeData = {
.size = sizeof(InterpreterObject),
.name = "interpreter",
.load = (object_load) InterpreterObject::load,
};
};

View file

@ -1,8 +1,4 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/intobject.h"
using namespace obj;
@ -71,4 +67,4 @@ struct obj::ObjectType obj::IntObject::TypeData = {
.save_size = (object_save_size) save_size,
.save = (object_save) save,
.load = (object_load) load,
};
};

View file

@ -1,8 +1,5 @@
#pragma once
#include "primitives/linkobject.h"
#include "NewPlacement.hpp"
using namespace obj;
using namespace tp;
@ -106,4 +103,4 @@ struct obj::ObjectType LinkObject::TypeData = { .base = NULL,
.type_methods = { .methods = {
&tm_set,
&tm_get,
} } };
} } };

View file

@ -1,8 +1,4 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/intobject.h"
#include "primitives/listobject.h"
@ -130,4 +126,4 @@ struct obj::ObjectType obj::ListObject::TypeData = { .base = NULL,
.load = (object_load) load,
.childs_retrival = (object_debug_all_childs_retrival) childs_retrival,
.allocated_size = (object_allocated_size) allocated_size,
.allocated_size_recursive = (object_allocated_size_recursive) allocated_size_recursive };
.allocated_size_recursive = (object_allocated_size_recursive) allocated_size_recursive };

View file

@ -1,6 +1,3 @@
#pragma once
#include "NewPlacement.hpp"
#include "compiler/function.h"
#include "core/scriptsection.h"
@ -62,4 +59,4 @@ MethodObject* MethodObject::create(tp::String script) {
out->mScript->mReadable->val = script;
out->compile();
return out;
}
}

View file

@ -1,7 +1,4 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/nullobject.h"
@ -47,4 +44,4 @@ struct ObjectType NullObject::TypeData = {
.size = sizeof(NullObject),
.name = "null",
.convesions = &NullObjectTypeConversions,
};
};

View file

@ -1,7 +1,4 @@
#pragma once
#include "NewPlacement.hpp"
#include "primitives/stringobject.h"
@ -75,4 +72,4 @@ struct obj::ObjectType StringObject::TypeData = {
.load = (object_load) load,
.comparison = (object_compare) compare_strings,
.allocated_size = (object_allocated_size) allocated_size,
};
};

View file

@ -1,8 +1,5 @@
#pragma once
#include "primitives/typeobject.h"
#include "NewPlacement.hpp"
#include "primitives/nullobject.h"
using namespace obj;
@ -69,4 +66,4 @@ struct obj::ObjectType TypeObject::TypeData = {
.load = (object_load) load,
.comparison = (object_compare) comparator,
.allocated_size = (object_allocated_size) allocated_size,
};
};

View file

@ -7,7 +7,8 @@
namespace obj {
namespace BCgen {
struct ConstObject {
class ConstObject {
public:
obj::Object* mObj = NULL;
tp::alni mConstIdx = 0;
@ -16,7 +17,8 @@ namespace obj {
};
struct ConstObjectsPool {
class ConstObjectsPool {
public:
tp::Map<tp::String, ConstObject*> mMethods;
tp::Map<tp::String, ConstObject*> mStrings;
tp::Map<tp::alni, ConstObject*> mIntegers;
@ -36,6 +38,7 @@ namespace obj {
ConstObject* registerObject(obj::Object* obj);
void save(tp::Buffer<ConstData>& out);
ConstObjectsPool() = default;
~ConstObjectsPool();
};
};

View file

@ -18,7 +18,7 @@ namespace obj {
NONE,
NEW,
LOCAL,
CONST,
CONST_EXPR,
CHILD,
CALL,
ARIPHM,

View file

@ -10,16 +10,17 @@
namespace obj {
namespace BCgen {
struct ConstObject;
class ConstObject;
struct Instruction {
class Instruction {
public:
OpCode mOp = OpCode::NONE;
enum class ArgType : tp::ualni {
NO_ARG,
PARAM,
CONST,
CONST_ARG,
} mArgType = ArgType::NO_ARG;
enum class InstType : tp::ualni {

View file

@ -1,5 +1,5 @@
#pragma once
#include "NewPlacement.hpp"
#include "compiler/statement.h"
#include "compiler/expression.h"
@ -192,4 +192,4 @@ namespace obj {
BCgen::StatementScope* parseScope(bool aPushToScopeStack);
};
};
};

View file

@ -1,5 +1,4 @@
#include "NewPlacement.hpp"
#include "Testing.hpp"
#include "primitives/primitives.h"
@ -32,4 +31,4 @@ int main() {
}
return 0;
}
}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "Testing.hpp"
#include "core/object.h"
@ -30,4 +28,4 @@ TEST_DEF_STATIC(BasicAPI) {
NDO->destroy(savedInt);
}
TEST_DEF(Core) { testBasicAPI(); }
TEST_DEF(Core) { testBasicAPI(); }

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "Testing.hpp"
#include "compiler/function.h"
@ -84,4 +82,4 @@ TEST_DEF_STATIC(Simple) {
TEST_DEF(Interpreter) {
testSimple();
// testComplex();
}
}

View file

@ -1,6 +1,4 @@
#include "NewPlacement.hpp"
#include "Testing.hpp"
#include "core/object.h"
@ -30,4 +28,4 @@ TEST_DEF_STATIC(Dict) {
NDO->destroy(dictLoaded);
}
TEST_DEF(Primitives) { testDict(); }
TEST_DEF(Primitives) { testDict(); }