Skip to content

Commit

Permalink
Some minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjoseph1995 committed Apr 20, 2023
1 parent d59e105 commit 6160a14
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ project(lox_cpp)
# Compile commands json generation
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# C++ standard
set(CMAKE_CXX_STANDARD 23)

# CCACHE Setup
if (CCACHE_FOUND)
message(CCACHE_FOUND)
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# C++ standard
set(CMAKE_CXX_STANDARD 23)

add_library(lox_compiler STATIC
chunk.cpp
virtual_machine.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ auto Heap::insertAtHead(Object* new_node) -> void
auto Heap::collectGarbage() -> void
{
GCDebugLog("Begining garbage collection");
/*
* TODO
*/
GCDebugLog("Garbage collection complete");
}

auto Heap::freeObject(Object* object) -> void
Expand Down
16 changes: 8 additions & 8 deletions src/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ enum class ObjectType {
};

struct Object {
public:
[[nodiscard]] auto GetType() const -> ObjectType
{
return type;
Expand All @@ -33,14 +32,15 @@ struct Object {
marked = true;
}

protected:
Object() = delete;

Object(ObjectType type)
: type(type)
{
}

friend class Heap;
ObjectType type;
ObjectType type {};
Object* next = nullptr;
bool marked = false;
};
Expand All @@ -58,9 +58,9 @@ struct FunctionObject : public Object {
: Object(ObjectType::FUNCTION)
{
}
std::string function_name;
std::string function_name {};
uint32_t arity {};
Chunk chunk;
Chunk chunk {};
uint16_t upvalue_count {};
};

Expand All @@ -70,7 +70,7 @@ struct NativeFunctionObject : public Object {
: Object(ObjectType::NATIVE_FUNCTION)
{
}
NativeFunction native_function;
NativeFunction native_function { nullptr };
};

struct UpvalueObject : public Object {
Expand Down Expand Up @@ -107,15 +107,15 @@ struct UpvalueObject : public Object {
}

private:
std::variant<Value, uint16_t> m_data;
std::variant<Value, uint16_t> m_data {};
};

struct ClosureObject : Object {
ClosureObject()
: Object(ObjectType::CLOSURE)
{
}
std::vector<UpvalueObject*> upvalues;
std::vector<UpvalueObject*> upvalues {};
FunctionObject const* function = nullptr;
};
#endif // LOX_CPP_OBJECT_H
1 change: 0 additions & 1 deletion src/value_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#ifndef LOX_CPP_VALUE_FORMATTER_H
#define LOX_CPP_VALUE_FORMATTER_H

#include <exception>
#include <fmt/core.h>

#include "object.h"
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# C++ standard
set(CMAKE_CXX_STANDARD 23)

add_executable(test_compiler test_compiler.cpp test_virtual_machine.cpp main.cpp)
target_link_libraries(test_compiler gtest_main lox_compiler fmt)
add_test(NAME test_compiler COMMAND test_compiler)
Expand Down

0 comments on commit 6160a14

Please sign in to comment.