Skip to content

Commit

Permalink
Fix Windows bugs (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: Gin <65128789+KThankYou@users.noreply.github.com>
  • Loading branch information
GinOwO and GinOwO authored Oct 3, 2023
1 parent b350a7a commit 0f4310c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ qt_add_executable(Caelum
src/ui/outputview.h src/ui/outputview.cpp src/ui/outputview.ui
)

if(WIN32)
set_property(TARGET Caelum PROPERTY WIN32_EXECUTABLE true)
endif()

target_link_libraries(Caelum PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

target_include_directories(Caelum PRIVATE
Expand Down
6 changes: 6 additions & 0 deletions resources/qss/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,9 @@ QStatusBar {
QToolTip {
background-color: black; color: white; border: 1px solid white;
}

QMessageBox {
background-color: rgb(42, 42, 42); /* Dark background color */
color: rgb(255, 255, 255); /* Text color */
}

24 changes: 24 additions & 0 deletions resources/qss/light.qss
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,27 @@ QMenu::item:selected {
QToolTip {
background-color: black; color: white; border: 1px solid white;
}

QHeaderView {
background-color: rgb(42, 42, 42); /* Dark background color */
color: rgb(255, 255, 255); /* Text color */
border-color: rgb(58, 58, 58);
border-style: solid;
border-width: 1px;
}

QHeaderView::section {
background-color: rgb(42, 42, 42); /* Dark background color */
color: rgb(255, 255, 255); /* Text color */
padding: 4px; /* Adjust padding as needed */
border-color: rgb(58, 58, 58);
border-style: solid;
border-width: 1px;
border-bottom: none; /* Remove the bottom border to separate sections */
}

/* Hover effect for the header section (column) */
QHeaderView::section:hover {
background-color: rgb(58, 58, 58); /* Hover background color */
color: rgb(255, 255, 255); /* Hover text color */
}
19 changes: 14 additions & 5 deletions src/main/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ unsigned long long Interpreter::POP(){
*/
void Interpreter::execute(){
if(code.size() == 0) throw Exception::BadSyntaxException("Code not built");
size_t backup_ptr = ptr;
this->output.clear();
int cnt, i, type, lineNum, memTemp1, memTemp2;
unsigned long long a, b, val;
Expand Down Expand Up @@ -222,29 +223,37 @@ void Interpreter::execute(){

}
}
catch(Exception::HaltException){return;}
catch(Exception::HaltException){
ptr = backup_ptr;
return;
}
catch(Exception::BadInstructionException){
ptr = backup_ptr;
throw Exception::BadSyntaxException("Bad instruction at line "+std::to_string(lineNum));
}
catch(Exception::UnknownException){
ptr = backup_ptr;
throw Exception::BadSyntaxException("Unknown error at line "+std::to_string(lineNum));
}
catch(Exception::PointerOutOfBoundsException){
ptr = backup_ptr;
throw Exception::BadSyntaxException("Pointer out of bounds at line "+std::to_string(lineNum));
}
catch(Exception::StackUnderflowException){
ptr = backup_ptr;
throw Exception::BadSyntaxException("Popping from empty stack at line "+std::to_string(lineNum));
}
}
}
ptr = backup_ptr;
}

void Interpreter::build(const std::string& instructions){
size_t h = std::hash<std::string>{}(instructions);
if(hash == h) return;
this->code.clear();
this->labelMap.clear();
this->callStack = std::stack<unsigned long long>();
unsigned long long i=0, j=0;
size_t h = std::hash<std::string>{}(instructions);
if(hash == h) return;
std::string label, op, op1, op2, instr;
std::stringstream ss(instructions);

Expand Down Expand Up @@ -323,7 +332,7 @@ void Interpreter::build(const std::string& instructions){
i++;
}
if(!this->labelMap.count(ptr)) throw Exception::MissingGlobalException();
ptr = this->labelMap[ptr];
ptr = this->labelMap[ptr]; // TODO backup ptr for next run
this->resolveLabels();
hash = h;
}
Expand Down

0 comments on commit 0f4310c

Please sign in to comment.