Apply formating to all files. CLeanup

This commit is contained in:
IlyaShurupov 2023-10-22 17:07:28 +03:00 committed by Ilya Shurupov
parent b4ae5dde77
commit 91fb72bd49
928 changed files with 14515 additions and 21479 deletions

View file

@ -1,49 +1,48 @@
#include "Compiler/Compiler.h"
#include "primitives/primitives.h"
#include "MethodObject/MethodObject.h"
#include "log.h"
using namespace osc;
using namespace tp;
using namespace obj;
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
Compiler compiler;
tp::string script;
RelAssert(argc == 2 && "Invalid Arguments");
script.loadFile(argv[1]);
compiler.compile(script);
GLog->write("oscc : compilation finished", 1);
}
try {
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
}
catch (...) {
tp::terminate();
}
#include "Compiler/Compiler.h"
#include "MethodObject/MethodObject.h"
#include "log.h"
#include "primitives/primitives.h"
using namespace osc;
using namespace tp;
using namespace obj;
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
Compiler compiler;
tp::string script;
RelAssert(argc == 2 && "Invalid Arguments");
script.loadFile(argv[1]);
compiler.compile(script);
GLog->write("oscc : compilation finished", 1);
}
try {
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
} catch (...) {
tp::terminate();
}
}

View file

@ -20,9 +20,7 @@ namespace ImGui {
bool ishovered = false;
tp::Vec2F p1;
tp::Vec2F p2;
operator bool() {
return opened;
}
operator bool() { return opened; }
};
PopupData HoverPopupBegin(const char* id, tp::Vec2F size, tp::Vec2F pos = tp::Vec2F(-1), int flags = 0);
@ -40,8 +38,7 @@ ImGui::PopupData ImGui::HoverPopupBegin(const char* str_id, tp::Vec2F size, tp::
if (pos_p == tp::Vec2F(-1)) {
pos = GImGui->CurrentWindow->DC.CursorPos;
}
else {
} else {
pos.x = pos_p.x;
pos.y = pos_p.y;
}
@ -62,7 +59,6 @@ ImGui::PopupData ImGui::HoverPopupBegin(const char* str_id, tp::Vec2F size, tp::
out.p1 = { pos.x, pos.y };
out.p2 = out.p1;
out.p2.x += ImGui::GetWindowWidth();
}
return out;
}
@ -87,7 +83,6 @@ void ImGui::HoverPopupEnd(ImGui::PopupData& in) {
EndPopup();
}
obj::ObjectsGUI::~ObjectsGUI() {
if (mClipboard) {
obj::NDO->destroy(mClipboard);
@ -109,9 +104,7 @@ void obj::ObjectsGUI::setClipboard(obj::Object* obj) {
}
}
obj::Object* obj::ObjectsGUI::getClipboard() {
return mClipboard;
}
obj::Object* obj::ObjectsGUI::getClipboard() { return mClipboard; }
obj::Object* imgui_object_create_menu(obj::TypeGroups* type_group = NULL) {
@ -134,8 +127,7 @@ obj::Object* imgui_object_create_menu(obj::TypeGroups* type_group = NULL) {
if (ImGui::Button((childo->key).read(), { 100, 0 })) {
if (childo->key == "null") {
newo = NDO_NULL;
}
else {
} else {
newo = obj::NDO->create(childo->key);
}
}
@ -144,9 +136,7 @@ obj::Object* imgui_object_create_menu(obj::TypeGroups* type_group = NULL) {
return newo;
}
obj::ObjectsGUI::ObjectsGUI() {
assert(obj::NDO && "Objects library is not initialized");
}
obj::ObjectsGUI::ObjectsGUI() { assert(obj::NDO && "Objects library is not initialized"); }
void obj::ObjectsGUI::cd(obj::Object* child, tp::String name) {
mActive = child;
@ -178,8 +168,7 @@ void obj::ObjectsGUI::preview(obj::Object* obj) {
if (link_lookup.presents(tp::alni(link_iter))) {
no_link_preview = true;
}
else {
} else {
link_lookup.put(tp::alni(link_iter), 0);
}
no_link_preview |= max_depth < depth_count;
@ -190,22 +179,18 @@ void obj::ObjectsGUI::preview(obj::Object* obj) {
ImGui::Text("=> ");
ImGui::SameLine();
preview(linko->getLink());
}
else {
} else {
ImGui::Text("Max preview depth exceeded");
}
}
else {
} else {
ImGui::Text("Link Is Null");
}
}
else if (NDO_CAST(obj::IntObject, obj)) {
} else if (NDO_CAST(obj::IntObject, obj)) {
tp::alni& val = NDO_CAST(obj::IntObject, obj)->val;
int gui_val = int(val);
ImGui::InputInt(" ", &gui_val);
val = tp::alni(gui_val);
}
else if (NDO_CAST(obj::StringObject, obj)) {
} else if (NDO_CAST(obj::StringObject, obj)) {
NDO_CASTV(obj::StringObject, obj, stringo);
static char val[2048] = { " " };
if (stringo->val != val) {
@ -216,25 +201,21 @@ void obj::ObjectsGUI::preview(obj::Object* obj) {
if (stringo->val != val) {
stringo->val = val;
}
}
else if (NDO_CAST(obj::BoolObject, obj)) {
boolView((obj::BoolObject*)obj);
}
else if (NDO_CAST(obj::FloatObject, obj)) {
} else if (NDO_CAST(obj::BoolObject, obj)) {
boolView((obj::BoolObject*) obj);
} else if (NDO_CAST(obj::FloatObject, obj)) {
tp::alnf& val = NDO_CAST(obj::FloatObject, obj)->val;
auto gui_val = float(val);
ImGui::InputFloat(" ", &gui_val);
val = tp::alnf(gui_val);
}
else if (NDO_CAST(obj::EnumObject, obj)) {
enumView((obj::EnumObject*)obj);
}
else if (NDO_CAST(obj::ColorObject, obj)) {
colorView((obj::ColorObject*)obj);
}
else {
ImGui::Text(obj->type->name); ImGui::SameLine();
} else if (NDO_CAST(obj::EnumObject, obj)) {
enumView((obj::EnumObject*) obj);
} else if (NDO_CAST(obj::ColorObject, obj)) {
colorView((obj::ColorObject*) obj);
} else {
ImGui::Text(obj->type->name);
ImGui::SameLine();
ImGui::Text(" (No Preview) ");
}
}
@ -261,12 +242,15 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
}
// running state
BeginChild("dockable"); {
BeginChild("dockable");
{
auto id = ImGui::GetCurrentWindow()->ID;
DockSpace(id);
} EndChild();
}
EndChild();
Begin("ByteCodeView"); {
Begin("ByteCodeView");
{
if (Button("Step")) {
interp.stepBytecode();
@ -299,21 +283,21 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
const auto bytecode = interp.mCallStack.getBytecode();
tp::halni idx = 0;
for (auto ip = 0; ip < bytecode->mInstructions.size(); ) {
for (auto ip = 0; ip < bytecode->mInstructions.size();) {
auto opcode = bytecode->mInstructions[ip];
auto info = obj::gOpcodeInfos.fetch(opcode);
PushID(info.name);
TextColored(ImVec4(1.f, 1.f, 1.f, 0.5f), "%i", idx); SameLine();
TextColored(ImVec4(1.f, 1.f, 1.f, 0.5f), "%i", idx);
SameLine();
if (bytecode->mInstructionIdx == ip) {
TextColored(ImVec4(1.f, 0.5f, 0.5f, 1.f), info.name);
}
else {
} else {
Text(info.name);
}
// INFO
auto hd = HoverPopupBegin(tp::String((tp::alni)ip).read(), { 400, 250 });
auto hd = HoverPopupBegin(tp::String((tp::alni) ip).read(), { 400, 250 });
if (hd) {
Text(info.desc);
if (info.operands.len) {
@ -339,43 +323,45 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
}
EndChild();
} End();
}
End();
Begin("SourceCodeView"); {
stringView(interp.mCallStack.mStack.last().mMethod->mScript->mReadable);
} End();
Begin("SourceCodeView");
{ stringView(interp.mCallStack.mStack.last().mMethod->mScript->mReadable); }
End();
Begin("OperandStack"); {
Begin("OperandStack");
{
if (!interp.mOperandsStack.mIdx) {
Text("No Operands");
}
for (auto i = 0; i < interp.mOperandsStack.mIdx; i++) {
auto operand = interp.mOperandsStack.mBuff[i];
tp::alni operand_val = (tp::alni)operand;
tp::alni operand_val = (tp::alni) operand;
if (operand_val == NULL) {
Text("NULL");
}
else if (tp::uint2(operand_val) == NULL) {
} else if (tp::uint2(operand_val) == NULL) {
Text("2 BYTE VAL : %i", tp::uint2(operand_val));
}
else {
} else {
if (Selectable(operand->type->name, false, 0, ImVec2(100, 0))) {
End();
return { operand, "operand" };
}
SameLine();
PushID((tp::alni)operand);
PushID((tp::alni) operand);
preview(operand);
PopID();
}
}
} End();
}
End();
Begin("ScopeStack"); {
Begin("ScopeStack");
{
for (auto i = 0; i < interp.mScopeStack.mIdx; i++) {
if (TreeNode(tp::String((tp::alni)i).read())) {
if (TreeNode(tp::String((tp::alni) i).read())) {
auto& scope = interp.mScopeStack.mBuff[i];
@ -412,9 +398,11 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
TreePop();
}
}
} End();
}
End();
Begin("CallStack"); {
Begin("CallStack");
{
for (auto i = 0; i < interp.mCallStack.mStack.size(); i++) {
auto method = interp.mCallStack.mStack[i].mMethod;
PushID(i);
@ -425,9 +413,11 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
}
PopID();
}
} End();
}
End();
Begin("ConstPool"); {
Begin("ConstPool");
{
auto bc = interp.mCallStack.getBytecode();
tp::alni idx = 0;
for (auto const_obj : bc->mConstants) {
@ -435,14 +425,15 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::interpreterView(obj::Interpreter
if (Button(const_obj.data()->type->name)) {
End();
PopID();
return {const_obj.data(), tp::String(idx)};
return { const_obj.data(), tp::String(idx) };
}
SameLine();
preview(const_obj.data());
PopID();
idx++;
}
} End();
}
End();
return {};
}
@ -452,7 +443,6 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::colorView(obj::ColorObject* in)
return {};
}
obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::enumView(obj::EnumObject* obj) {
if (!obj->entries) {
@ -504,8 +494,7 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::linkoView(obj::LinkObject* obj)
if (ImGui::Selectable("View")) {
return { obj->getLink(), "adress" };
}
}
else {
} else {
ImGui::Text("Link Is Null");
}
@ -524,10 +513,11 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::linkoView(obj::LinkObject* obj)
}
obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::intoView(obj::IntObject* obj) {
ImGui::Text("Int Value: "); ImGui::SameLine();
int val = (int)obj->val;
ImGui::Text("Int Value: ");
ImGui::SameLine();
int val = (int) obj->val;
ImGui::InputInt(" ", &val);
obj->val = (tp::alni)val;
obj->val = (tp::alni) val;
return {};
}
@ -581,20 +571,18 @@ void obj::ObjectsGUI::dictViewEdit(obj::DictObject* dict, tp::String key, obj::O
if (key.size() > 100) {
ImGui::Text("name is too large");
}
else {
} else {
if (mLastNameEditObject != obj) {
tp::memCopy(mNameEdit, key.read(), key.size() + 1);
mLastNameEditObject = obj;
}
if (ImGui::InputTextEx(" ", "new name", mNameEdit, 100, { 140 , 30 }, ImGuiInputTextFlags_EnterReturnsTrue)) {
if (ImGui::InputTextEx(" ", "new name", mNameEdit, 100, { 140, 30 }, ImGuiInputTextFlags_EnterReturnsTrue)) {
auto idx = dict->presents(mNameEdit);
if (bool(idx)) {
//Notify("Object with such name Already Exists");
}
else {
// Notify("Object with such name Already Exists");
} else {
obj::NDO->refinc(obj);
dict->remove(key);
auto id = tp::String(mNameEdit);
@ -620,7 +608,8 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::dictView(obj::DictObject* obj) {
bool popup = false;
auto table_flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable;
ImGui::BeginChild("frame", { 0, 0 }, 0, ImGuiWindowFlags_NoBackground); {
ImGui::BeginChild("frame", { 0, 0 }, 0, ImGuiWindowFlags_NoBackground);
{
if (!obj->getItems().size()) {
ImGui::Text("Dictinary Is Empty. ");
}
@ -629,27 +618,27 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::dictView(obj::DictObject* obj) {
ImGui::TableSetupColumn("name");
ImGui::TableSetupColumn("info");
for (auto childo : obj->getItems()) {
ImGui::TableNextRow(0, 30);
ImGui::TableSetColumnIndex(0);
if (ImGui::Selectable(childo->key.read())) {
ImGui::EndTable();
ImGui::EndChild();
return { childo->val, { tp::String(childo->val->type->name) + tp::String(" ") + childo->key } };
return { childo->val, { tp::String(childo->val->type->name) + tp::String(" ") + childo->key } };
}
dictViewEdit(obj, childo->key, childo->val, popup);
ImGui::TableSetColumnIndex(1);
ImGui::PushID((int)childo->key.read()[0]);
ImGui::PushID((int) childo->key.read()[0]);
preview(childo->val);
ImGui::PopID();
}
ImGui::EndTable();
}
} ImGui::EndChild();
}
ImGui::EndChild();
if (!popup) {
dictViewDrawCreate(obj);
@ -678,7 +667,7 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::listView(obj::ListObject* obj) {
ImGui::TableSetColumnIndex(0);
if (ImGui::Selectable(tp::String(idx).read())) {
out = ViewStackNode(childo.data(), { tp::String(childo->type->name) + tp::String("at") + tp::String(idx) } );
out = ViewStackNode(childo.data(), { tp::String(childo->type->name) + tp::String("at") + tp::String(idx) });
break;
}
@ -718,7 +707,7 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::listView(obj::ListObject* obj) {
ImGui::TableSetColumnIndex(1);
ImGui::PushID((int)idx);
ImGui::PushID((int) idx);
preview(childo.data());
ImGui::PopID();
@ -758,7 +747,7 @@ void drawStrView(tp::String& in) {
}
ImGui::BeginChild("str_edit");
ImGui::InputTextMultiline(" ", val, 2048, { ImGui::GetWindowWidth() , ImGui::GetWindowHeight() });
ImGui::InputTextMultiline(" ", val, 2048, { ImGui::GetWindowWidth(), ImGui::GetWindowHeight() });
ImGui::EndChild();
if (in != val) {
@ -811,16 +800,15 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::classView(obj::ClassObject* self
ImGui::EndTable();
ImGui::TreePop();
ImGui::EndChild();
return { childo->val, { tp::String(childo->val->type->name) + childo->key } };
return { childo->val, { tp::String(childo->val->type->name) + childo->key } };
}
dictViewEdit(dict, childo->key, childo->val, popup);
ImGui::TableSetColumnIndex(1);
ImGui::PushID((int)idx);
ImGui::PushID((int) idx);
preview(childo->val);
ImGui::PopID();
}
ImGui::EndTable();
@ -829,13 +817,13 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::classView(obj::ClassObject* self
ImGui::TreePop();
}
if (n_methods && ImGui::TreeNodeBehavior(window->GetID("Methods"), tree_flags, "Methods", 0) ) {
if (n_methods && ImGui::TreeNodeBehavior(window->GetID("Methods"), tree_flags, "Methods", 0)) {
for (auto childo : dict->getItems()) {
if (childo->val->type == &obj::MethodObject::TypeData) {
if (ImGui::Selectable(childo->key.read())) {
ImGui::TreePop();
ImGui::EndChild();
return { childo->val, { tp::String(childo->val->type->name) + childo->key } };
return { childo->val, { tp::String(childo->val->type->name) + childo->key } };
}
dictViewEdit(dict, childo->key, childo->val, popup);
}
@ -865,8 +853,7 @@ obj::ObjectsGUI::ViewStackNode obj::ObjectsGUI::methodView(obj::MethodObject* in
interp.execAll(in);
}
}
else {
} else {
if (ImGui::Button("Compile")) {
in->compile();
}
@ -897,13 +884,14 @@ void obj::ObjectsGUI::explorer() {
tp::alni idx = 0;
for (auto childo = rev_path.last(); childo; childo = childo->prev) {
ImGui::PushID((int)idx);
ImGui::PushID((int) idx);
bool go_back = false;
if (childo == rev_path.last()) {
go_back = ImGui::Button(childo->data->id.read()); ImGui::SameLine();
}
else {
go_back = ImGui::Button((childo->data->id).read()); ImGui::SameLine();
go_back = ImGui::Button(childo->data->id.read());
ImGui::SameLine();
} else {
go_back = ImGui::Button((childo->data->id).read());
ImGui::SameLine();
}
ImGui::PopID();
@ -919,7 +907,7 @@ void obj::ObjectsGUI::explorer() {
if (ImGui::Selectable("Instantiate ")) {
setClipboard(obj::NDO->instatiate(curretn_object));
//Notify("Object copied to clipboard");
// Notify("Object copied to clipboard");
}
ImGui::Separator();
@ -929,22 +917,22 @@ void obj::ObjectsGUI::explorer() {
ImGui::InputTextEx(" ", "save path", path_str, 100, { 100, 30 }, 0);
bool save_object = ImGui::Button("Save Object");
ImGui::SameLine(); ImGui::Checkbox("Compressed", &compressed);
ImGui::SameLine();
ImGui::Checkbox("Compressed", &compressed);
bool load_object = ImGui::Button("Load Object");
if (save_object) {
obj::NDO->save(curretn_object, path_str, compressed);
//Notify("Object saved");
// Notify("Object saved");
}
if (load_object) {
obj::Object* loadedo = obj::NDO->load(path_str);
if (loadedo) {
setClipboard(loadedo);
//Notify("Object copied to clipboard");
}
else {
//Notify("Can't load Object");
// Notify("Object copied to clipboard");
} else {
// Notify("Can't load Object");
}
}
@ -968,45 +956,32 @@ void obj::ObjectsGUI::explorer() {
ViewStackNode new_active;
if (NDO_CAST(obj::NullObject, mActive)) {
new_active = nullView((obj::NullObject*)mActive);
}
else if (NDO_CAST(obj::LinkObject, mActive)) {
new_active = linkoView((obj::LinkObject*)mActive);
}
else if (NDO_CAST(obj::IntObject, mActive)) {
new_active = intoView((obj::IntObject*)mActive);
}
else if (NDO_CAST(obj::StringObject, mActive)) {
new_active = stringView((obj::StringObject*)mActive);
}
else if (NDO_CAST(obj::ListObject, mActive)) {
new_active = listView((obj::ListObject*)mActive);
}
else if (NDO_CAST(obj::DictObject, mActive)) {
new_active = dictView((obj::DictObject*)mActive);
}
else if (NDO_CAST(obj::InterpreterObject, mActive)) {
new_active = interpreterView((obj::InterpreterObject*)mActive);
}
else if (NDO_CAST(obj::ClassObject, mActive)) {
new_active = classView((obj::ClassObject*)mActive);
}
else if (NDO_CAST(obj::BoolObject, mActive)) {
new_active = boolView((obj::BoolObject*)mActive);
}
else if (NDO_CAST(obj::FloatObject, mActive)) {
new_active = floatView((obj::FloatObject*)mActive);
}
else if (NDO_CAST(obj::EnumObject, mActive)) {
new_active = enumView((obj::EnumObject*)mActive);
}
else if (NDO_CAST(obj::MethodObject, mActive)) {
new_active = methodView((obj::MethodObject*)mActive);
}
else if (NDO_CAST(obj::ColorObject, mActive)) {
new_active = colorView((obj::ColorObject*)mActive);
}
else {
new_active = nullView((obj::NullObject*) mActive);
} else if (NDO_CAST(obj::LinkObject, mActive)) {
new_active = linkoView((obj::LinkObject*) mActive);
} else if (NDO_CAST(obj::IntObject, mActive)) {
new_active = intoView((obj::IntObject*) mActive);
} else if (NDO_CAST(obj::StringObject, mActive)) {
new_active = stringView((obj::StringObject*) mActive);
} else if (NDO_CAST(obj::ListObject, mActive)) {
new_active = listView((obj::ListObject*) mActive);
} else if (NDO_CAST(obj::DictObject, mActive)) {
new_active = dictView((obj::DictObject*) mActive);
} else if (NDO_CAST(obj::InterpreterObject, mActive)) {
new_active = interpreterView((obj::InterpreterObject*) mActive);
} else if (NDO_CAST(obj::ClassObject, mActive)) {
new_active = classView((obj::ClassObject*) mActive);
} else if (NDO_CAST(obj::BoolObject, mActive)) {
new_active = boolView((obj::BoolObject*) mActive);
} else if (NDO_CAST(obj::FloatObject, mActive)) {
new_active = floatView((obj::FloatObject*) mActive);
} else if (NDO_CAST(obj::EnumObject, mActive)) {
new_active = enumView((obj::EnumObject*) mActive);
} else if (NDO_CAST(obj::MethodObject, mActive)) {
new_active = methodView((obj::MethodObject*) mActive);
} else if (NDO_CAST(obj::ColorObject, mActive)) {
new_active = colorView((obj::ColorObject*) mActive);
} else {
ImGui::Text("Preview is Unavaliable");
}
@ -1028,8 +1003,7 @@ void obj::ObjectsGUI::properties(const obj::ObjectType* type, bool top_of_tree_v
if (ImGui::TreeNode("Description ")) {
if (type->description) {
ImGui::Text(type->description);
}
else {
} else {
ImGui::Text("Description is not given");
}
ImGui::TreePop();
@ -1052,7 +1026,7 @@ void obj::ObjectsGUI::properties(const obj::ObjectType* type, bool top_of_tree_v
ImGui::TreePop();
}
//if (ImGui::TreeNode("Full Type Hierarchy")) {
// if (ImGui::TreeNode("Full Type Hierarchy")) {
ImGui::Text("RAM : ");
ImGui::Indent();
@ -1067,16 +1041,15 @@ void obj::ObjectsGUI::properties(const obj::ObjectType* type, bool top_of_tree_v
ImGui::Text("With Object Links : %i bytes", obj::NDO->objsize_file_recursive(mActive));
ImGui::Unindent();
//ImGui::TreePop();
//}
// ImGui::TreePop();
//}
ImGui::TreePop();
}
if (ImGui::TreeNode("Base Type")) {
if (type->base) {
properties(type->base, false);
}
else {
} else {
ImGui::Text("No base type");
}
ImGui::TreePop();
@ -1099,8 +1072,7 @@ void obj::ObjectsGUI::draw() {
}
ImGui::End();
}
else {
} else {
ImGui::Text("ViewStack is Empty");
}

View file

@ -28,9 +28,7 @@ public:
}
}
~GUIWindow() {
Window::destroyWindow(window);
}
~GUIWindow() { Window::destroyWindow(window); }
};
int main() {

View file

@ -1,58 +1,58 @@
#include "MethodObject/methodobject.h"
#include "primitives/primitives.h"
#include "Interpreter/Interpreter.h"
#include "log.h"
using namespace osc;
using namespace tp;
using namespace obj;
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
time_ms load_start = get_time();
RelAssert(argc == 2 && "Invalid Arguments");
auto obj = NDO->load(argv[1]);
RelAssert(obj && "Failed to Load the File");
RelAssert(obj->type == &MethodObject::TypeData && "Innvalid file content");
Interpreter interp;
NDO_CASTV(MethodObject, obj, method);
RelAssert(method->mScript && "Innvalid file content");
time_ms load_end = get_time();
GLog->write("\noscvm - execution started\n");
time_ms exec_start = get_time();
interp.exec(&method->mScript->mBytecode);
time_ms exec_end = get_time();
auto exec_time = (exec_end - exec_start);
auto load_time = (load_end - load_start);
GLog->write(sfmt("\noscvm - execution finished (Load : %f Exec : %f)", load_time, exec_time));
}
try {
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
} catch (...) {
tp::terminate();
}
#include "MethodObject/methodobject.h"
#include "primitives/primitives.h"
#include "Interpreter/Interpreter.h"
#include "log.h"
using namespace osc;
using namespace tp;
using namespace obj;
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
time_ms load_start = get_time();
RelAssert(argc == 2 && "Invalid Arguments");
auto obj = NDO->load(argv[1]);
RelAssert(obj && "Failed to Load the File");
RelAssert(obj->type == &MethodObject::TypeData && "Innvalid file content");
Interpreter interp;
NDO_CASTV(MethodObject, obj, method);
RelAssert(method->mScript && "Innvalid file content");
time_ms load_end = get_time();
GLog->write("\noscvm - execution started\n");
time_ms exec_start = get_time();
interp.exec(&method->mScript->mBytecode);
time_ms exec_end = get_time();
auto exec_time = (exec_end - exec_start);
auto load_time = (load_end - load_start);
GLog->write(sfmt("\noscvm - execution finished (Load : %f Exec : %f)", load_time, exec_time));
}
try {
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
} catch (...) {
tp::terminate();
}
}

View file

@ -1,87 +1,89 @@
#include "primitives/methodobject.h"
#include "primitives/primitives.h"
#include "interpreter/interpreter.h"
#include "compiler/function.h"
using namespace tp;
using namespace obj;
void TestCompile(ByteCode& bytecode) {
using namespace BCgen;
Genereate(bytecode,
StmScope({
StmDefFunc("main", {}, {
StmDefLocal("i1", ExprConst(1)),
StmDefLocal("i2", ExprConst(2)),
//StmDefFunc("add", {"first", "second"}, {
// StmReturn(ExprAdd(ExprLocal("first"), ExprLocal("second")))
//}),
StmPrint(ExprLocal("i1")),
StmPrint(ExprConst(" + ")),
StmPrint(ExprLocal("i2")),
StmPrint(ExprConst(" = ")),
StmPrint(ExprFunc("add")->ExprCall({ ExprLocal("i1"), ExprLocal("i2") })),
StmPrint(ExprConst("\n")),
}),
StmPrint(ExprBoolNot(ExprConst(0))),
StmWhile(ExprConst(false), StmScope({
StmIgnore(ExprFunc("main")->ExprCall({}))
})
),
StmIf(ExprConst(true),
StmScope({
//StmIgnore(ExprFunc("main")->ExprCall({})),
//StmPrint(ExprConst("true")),
}),
StmScope({
//StmPrint(ExprConst("false")),
})
)
})
);
}
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
Interpreter interp;
ByteCode bytecode;
TestCompile(bytecode);
GLog->write(" >> Exec: start \n");
auto start = get_time();
interp.exec(&bytecode);
auto end = get_time();
GLog->write(sfmt("\n >> Exec time %i ms", end - start));
}
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
#include "primitives/methodobject.h"
#include "primitives/primitives.h"
#include "interpreter/interpreter.h"
#include "compiler/function.h"
using namespace tp;
using namespace obj;
void TestCompile(ByteCode& bytecode) {
using namespace BCgen;
Genereate(
bytecode,
StmScope({
StmDefFunc(
"main",
{},
{
StmDefLocal("i1", ExprConst(1)),
StmDefLocal("i2", ExprConst(2)),
// StmDefFunc("add", {"first", "second"}, {
// StmReturn(ExprAdd(ExprLocal("first"), ExprLocal("second")))
//}),
StmPrint(ExprLocal("i1")),
StmPrint(ExprConst(" + ")),
StmPrint(ExprLocal("i2")),
StmPrint(ExprConst(" = ")),
StmPrint(ExprFunc("add")->ExprCall({ ExprLocal("i1"), ExprLocal("i2") })),
StmPrint(ExprConst("\n")),
}
),
StmPrint(ExprBoolNot(ExprConst(0))),
StmWhile(ExprConst(false), StmScope({ StmIgnore(ExprFunc("main")->ExprCall({})) })),
StmIf(
ExprConst(true),
StmScope({
// StmIgnore(ExprFunc("main")->ExprCall({})),
// StmPrint(ExprConst("true")),
}),
StmScope({
// StmPrint(ExprConst("false")),
})
) })
);
}
int main(int argc, char* argv[]) {
tp::alloc_init();
string::Initialize();
Logger::init();
objects_init();
primitives_define_types();
MethodObject::Initialize();
{
Interpreter interp;
ByteCode bytecode;
TestCompile(bytecode);
GLog->write(" >> Exec: start \n");
auto start = get_time();
interp.exec(&bytecode);
auto end = get_time();
GLog->write(sfmt("\n >> Exec time %i ms", end - start));
}
MethodObject::UnInitialize();
objects_finalize();
primitives_uninitialize();
Logger::deinit();
string::UnInitialize();
tp::alloc_uninit();
}

View file

@ -1,75 +1,68 @@
#include "primitives/primitives.h"
#include "compiler/function.h"
#include "interpreter/interpreter.h"
#include "CmdArgParser.h"
void compile(char argc, const char* argv[]) {
tp::CmdArgParser args = {
{ "script", tp::CmdArgParser::Arg::FILE_IN },
{ "out", "out.mo" }
};
if (!args.parse(argc, argv, true)) {
return;
}
auto& script_file = args.getFile("script");
auto outpath = args.getString("out");
tp::string script;
script.loadFile(&script_file);
auto method = obj::MethodObject::create(script);
obj::NDO->save(method, outpath);
}
void execute(char argc, const char* argv[]) {
tp::CmdArgParser args = {
{ "object_path", tp::CmdArgParser::Arg::STR },
{ "debug", false }
};
if (!args.parse(argc, argv, true)) {
return;
}
auto object_path = args.getString("object_path");
auto debug = args.getBool("debug");
auto obj = obj::NDO->load(object_path);
if (!obj) {
printf("Invalid Object File\n");
return;
}
NDO_CASTV(obj::MethodObject, obj, method);
if (!method) {
printf("Object Is Not A Method\n");
return;
}
obj::Interpreter interpreter;
interpreter.execAll(method);
}
int main(char argc, const char* argv[]) {
tp::ModuleManifest* ModuleDependencies[] = { &obj::gModuleObjects, NULL };
tp::ModuleManifest TestModule("Test", NULL, NULL, ModuleDependencies);
if (!TestModule.initialize()) {
return 1;
}
#ifdef OBC
compile(argc, argv);
#elif OBVM
execute(argc, argv);
#endif // OBC
TestModule.deinitialize();
#include "primitives/primitives.h"
#include "compiler/function.h"
#include "interpreter/interpreter.h"
#include "CmdArgParser.h"
void compile(char argc, const char* argv[]) {
tp::CmdArgParser args = { { "script", tp::CmdArgParser::Arg::FILE_IN }, { "out", "out.mo" } };
if (!args.parse(argc, argv, true)) {
return;
}
auto& script_file = args.getFile("script");
auto outpath = args.getString("out");
tp::string script;
script.loadFile(&script_file);
auto method = obj::MethodObject::create(script);
obj::NDO->save(method, outpath);
}
void execute(char argc, const char* argv[]) {
tp::CmdArgParser args = { { "object_path", tp::CmdArgParser::Arg::STR }, { "debug", false } };
if (!args.parse(argc, argv, true)) {
return;
}
auto object_path = args.getString("object_path");
auto debug = args.getBool("debug");
auto obj = obj::NDO->load(object_path);
if (!obj) {
printf("Invalid Object File\n");
return;
}
NDO_CASTV(obj::MethodObject, obj, method);
if (!method) {
printf("Object Is Not A Method\n");
return;
}
obj::Interpreter interpreter;
interpreter.execAll(method);
}
int main(char argc, const char* argv[]) {
tp::ModuleManifest* ModuleDependencies[] = { &obj::gModuleObjects, NULL };
tp::ModuleManifest TestModule("Test", NULL, NULL, ModuleDependencies);
if (!TestModule.initialize()) {
return 1;
}
#ifdef OBC
compile(argc, argv);
#elif OBVM
execute(argc, argv);
#endif // OBC
TestModule.deinitialize();
}