From ae95a0c2cb637759b59952d8d37744830e219d1b Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Mon, 2 Jan 2023 18:00:59 +0100 Subject: [PATCH] Various code improvements --- README.md | 2 +- media/test-project/os-test.spice | 2 +- src/ast/ASTBuilder.cpp | 3 ++- src/typechecker/OpRuleManager.cpp | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f12baa490..a5cadc7da 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Use this command to run it: ``` #### Re-build Spice -To re-build Spice there is also a batch/shell script to help you with that. Use the following command to run it: +There is also a batch/shell script to rebuild Spice. Use the following command to run it: **Linux:**
```sh diff --git a/media/test-project/os-test.spice b/media/test-project/os-test.spice index 1b65e03ae..899feb1bb 100644 --- a/media/test-project/os-test.spice +++ b/media/test-project/os-test.spice @@ -1,7 +1,7 @@ f main() { int test = 123; int& testRef = test; - assert &test == &testRef; + assert test == testRef; } /*ext malloc(long); diff --git a/src/ast/ASTBuilder.cpp b/src/ast/ASTBuilder.cpp index 23541e119..d4ca94644 100644 --- a/src/ast/ASTBuilder.cpp +++ b/src/ast/ASTBuilder.cpp @@ -950,7 +950,8 @@ std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) { antlr4::ParserRuleContext *rule; if (rule = dynamic_cast(subTree); rule != nullptr) { // AssignExpr currentNode = assertStmtNode->createChild(CodeLoc(rule->start, filePath)); - assertStmtNode->expressionString = rule->getText(); + antlr4::misc::Interval interval(rule->start->getStartIndex(), rule->stop->getStopIndex()); + assertStmtNode->expressionString = inputStream->getText(interval); } else assert(dynamic_cast(subTree)); // Fail if we did not get a terminal diff --git a/src/typechecker/OpRuleManager.cpp b/src/typechecker/OpRuleManager.cpp index 647c101cf..357662de9 100644 --- a/src/typechecker/OpRuleManager.cpp +++ b/src/typechecker/OpRuleManager.cpp @@ -108,7 +108,7 @@ SymbolType OpRuleManager::getEqualResultType(const ASTNode *node, const SymbolTy // Allow 'pointer == pointer' straight away if (lhs.isPointer() && rhs.isPointer()) return SymbolType(TY_BOOL); - // Allow 'pointer == byte' straight away + // Allow 'pointer == int' straight away if (lhs.isPointer() && rhs.is(TY_INT)) return SymbolType(TY_BOOL); // Check primitive type combinations @@ -119,7 +119,7 @@ SymbolType OpRuleManager::getNotEqualResultType(const ASTNode *node, const Symbo // Allow 'pointer != pointer' straight away if (lhs.isPointer() && rhs.isPointer()) return SymbolType(TY_BOOL); - // Allow 'pointer != byte' straight away + // Allow 'pointer != int' straight away if (lhs.isPointer() && rhs.is(TY_INT)) return SymbolType(TY_BOOL); // Check primitive type combinations