Skip to content

Commit

Permalink
fix: printing LoadLiteral "\n" instruction failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mrunix00 committed Apr 17, 2024
1 parent 12c50d0 commit b6484c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bytecode/instructions/LoadLiteral.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ namespace Bytecode {
literal = StackObject(value);
};

explicit LoadLiteral(const StackObject *literal){
explicit LoadLiteral(const StackObject *literal) {
this->literal = *literal;
type = InstructionType::LoadLiteral;
}

[[nodiscard]] std::string toString() const override {
if (literal.type == ObjectType::String) {
std::string str = literal.toString();
if (str == "\n") str = "\\n";
return "LoadLiteral " + std::string("\"") + str + std::string("\"");
}
return "LoadLiteral " + literal.toString();
}

Expand Down

0 comments on commit b6484c0

Please sign in to comment.