Skip to content

Commit

Permalink
assert_emit("(2 4 3)#2", 4);
Browse files Browse the repository at this point in the history
		fails after 126 runs
  • Loading branch information
pannous committed Dec 25, 2023
1 parent 51cd03b commit 4991f4d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 31 deletions.
49 changes: 38 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.22
# Generated by "Unix Makefiles" Generator, CMake Version 3.27

# Default target executed when no arguments are given to make.
default_target: all
Expand Down Expand Up @@ -48,27 +48,27 @@ cmake_force:
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
CMAKE_COMMAND = /opt/homebrew/Cellar/cmake/3.27.7/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
RM = /opt/homebrew/Cellar/cmake/3.27.7/bin/cmake -E rm -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /wasp
CMAKE_SOURCE_DIR = /Users/me/wasp

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /wasp
CMAKE_BINARY_DIR = /Users/me/wasp

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
/opt/homebrew/Cellar/cmake/3.27.7/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache

# Special rule for the target edit_cache
Expand All @@ -77,8 +77,8 @@ edit_cache/fast: edit_cache

# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
/opt/homebrew/Cellar/cmake/3.27.7/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
Expand All @@ -87,9 +87,9 @@ rebuild_cache/fast: rebuild_cache

# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /wasp/CMakeFiles /wasp//CMakeFiles/progress.marks
$(CMAKE_COMMAND) -E cmake_progress_start /Users/me/wasp/CMakeFiles /Users/me/wasp//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /wasp/CMakeFiles 0
$(CMAKE_COMMAND) -E cmake_progress_start /Users/me/wasp/CMakeFiles 0
.PHONY : all

# The main clean target
Expand Down Expand Up @@ -729,6 +729,30 @@ source/smart_types.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/wasp.dir/build.make CMakeFiles/wasp.dir/source/smart_types.cpp.s
.PHONY : source/smart_types.cpp.s

source/tests.o: source/tests.cpp.o
.PHONY : source/tests.o

# target to build an object file
source/tests.cpp.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/wasp.dir/build.make CMakeFiles/wasp.dir/source/tests.cpp.o
.PHONY : source/tests.cpp.o

source/tests.i: source/tests.cpp.i
.PHONY : source/tests.i

# target to preprocess a source file
source/tests.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/wasp.dir/build.make CMakeFiles/wasp.dir/source/tests.cpp.i
.PHONY : source/tests.cpp.i

source/tests.s: source/tests.cpp.s
.PHONY : source/tests.s

# target to generate assembly for a file
source/tests.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/wasp.dir/build.make CMakeFiles/wasp.dir/source/tests.cpp.s
.PHONY : source/tests.cpp.s

source/wasm_emitter.o: source/wasm_emitter.cpp.o
.PHONY : source/wasm_emitter.o

Expand Down Expand Up @@ -957,6 +981,9 @@ help:
@echo "... source/smart_types.o"
@echo "... source/smart_types.i"
@echo "... source/smart_types.s"
@echo "... source/tests.o"
@echo "... source/tests.i"
@echo "... source/tests.s"
@echo "... source/wasm_emitter.o"
@echo "... source/wasm_emitter.i"
@echo "... source/wasm_emitter.s"
Expand Down
6 changes: 4 additions & 2 deletions source/Angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,10 @@ groupFunctionDeclaration(String &name, Node *return_type, Node modifieres, Node
// decl["signature"]=*new Node("signature");
if (signature.functions.size() == 0)
signature.functions.add(&function);
decl["signature"].value.data = &signature;
// decl["signature"].value.data = &signature;
auto pNode = new Node("signature");
pNode->value.data = &signature;
decl.addMeta(pNode);
// function.body= &body;
return decl;
}
Expand Down Expand Up @@ -1944,7 +1947,6 @@ void clearAnalyzerContext() {
globals.clear();
call_indices.clear();
call_indices.setDefault(-1);
functions.clear();
analyzed.clear();// todo move much into outer analyze function!
functions.clear();// always needs to be followed by
preRegisterFunctions();// BUG Signature wrong cpp file
Expand Down
4 changes: 3 additions & 1 deletion source/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ Node &Node::operator[](chars s) {
}
if (length == 1)
if (children[0].has(s))return children[0][s];

if (meta and meta->has(s)) {
return (*meta)[s];
}
Node &neu = set(s, 0);// for n["a"]=b // todo: return DANGLING/NIL
neu.kind = key;//nils; // until ref is set! but neu never knows when its set!! :(
neu.parent = (Node *) this;
Expand Down
2 changes: 1 addition & 1 deletion source/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class Node {


explicit Node(chars name) {
this->name = *new String(name);
this->name = String(name);
// type = strings NAH;// unless otherwise specified!
}

Expand Down
6 changes: 3 additions & 3 deletions source/Wasp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ class Wasp {
actual.setType(groups);// may be changed later, default (1 2)==1,2
#ifdef DEBUG
if (line != "}")
actual.line = &line.clone();
actual.line = &line;
#endif
auto length = text.length;
int start = at;// line, expression, group, … start
Expand Down Expand Up @@ -1562,7 +1562,7 @@ class Wasp {
object.separator = objectValue.separator;
#ifdef DEBUG
if (line != "}")
object.line = &line.clone();
object.line = &line;
#endif
if (asListItem)
actual.add(object);
Expand Down Expand Up @@ -1781,7 +1781,7 @@ class Wasp {
Node &node = expressione(close);//word();
#ifdef DEBUG
if (line != "}")
node.line = &line.clone();
node.line = &line;
#endif
if (contains(import_keywords, (chars) node.first().name.data)) { // use, include, require …
node = direct_include(actual, node);
Expand Down
1 change: 1 addition & 0 deletions source/test_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ void testArrayIndicesWasm() {

// testArrayIndices(); // check node based (non-primitive) interpretation first
// data_mode = true;// todo remove hack
clearAnalyzerContext();
assert_emit("x={1 2 3}; x#3=4;x#3", 4);
#if WASM
assert_emit("puts('ok');", -1);
Expand Down
30 changes: 18 additions & 12 deletions source/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Paint.h"

#pragma GCC diagnostic ignored "-Wdeprecated"

#import "test_angle.cpp"
#import "test_wast.cpp"
#import "test_wasm.cpp"
Expand Down Expand Up @@ -56,13 +57,15 @@ void testTypes() {


void testTypedFunctions() {
result = analyze(parse("int id(float b, string c){b}"));
// todo name 'id' clashes with 'id' in preRegisterFunctions()
result = analyze(parse("int tee(float b, string c){b}"));
check_is(result.kind, Kind::declaration);
check_is(result.name, "id");
check_is(result.name, "tee");
auto signature_node = result["signature"];
// auto signature_node = result.metas()["signature"];
if (not signature_node.value.data)error("no signature");
Signature &signature = *(Signature *) signature_node.value.data;
check_is(signature.functions.first()->name, "id")
check_is(signature.functions.first()->name, "tee")
check_is(signature.parameters.size(), 2)
check_is(signature.parameters.first().name, "b")
check_is(signature.parameters.first().type, reals);// use real / number for float64 float32
Expand Down Expand Up @@ -1444,10 +1447,10 @@ void testUnicode_UTF16_UTF32() {// constructors/ conversion maybe later
assert(interpret("ç='☺'") == String(L''));
assert(interpret("ç='☺'") == String(U''));
skip(
assert(interpret("ç='☺'") == String(u""));
assert(interpret("ç='☺'") == String(u8""));
assert(interpret("ç='☺'") == String(L""));
assert(interpret("ç='☺'") == String(U""));
assert(interpret("ç='☺'") == String(u""));
assert(interpret("ç='☺'") == String(u8""));
assert(interpret("ç='☺'") == String(L""));
assert(interpret("ç='☺'") == String(U""));
)
check(String(u'') == "");
check(String(L'') == "");
Expand Down Expand Up @@ -3269,12 +3272,15 @@ void testCurrent() {
// assert_emit("print('hi')", 0)
// assert_emit("puts('hi')", 8)
// exit(1);
// assert_emit("x={1 2 3}; x#3=4;x#3", 4);

testTypedFunctions();
testPolymorphism();
assert_emit("x={1 2 3}; x#3=4;x#3", 4);

for (int i = 0; i < 1000; i++) {
// testPolymorphism();
// testTypedFunctions();
print("OK >>> %d\n"s % i);
assert_emit("(2 4 3)#2", 4);
// assert_emit("x={1 2 3}; x#3=4;x#3", 4);
}
exit(1);
testTypes();
// assert_emit("√3^2", 3)
// testSinus();
Expand Down
2 changes: 1 addition & 1 deletion source/wasm_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ Primitive addTypeFromSize(Node &array, short size) {
else if (size == 4 and kind == longs)array.type = &IntegerType;
else if (size == 4 and kind == Kind::codepoint1)array.type = &CodepointType;
else if (size == 8 and kind == longs) array.type = &LongType;
else if (size == 8 and kind == reals) array.type = (Node *) &DoubleType;// const!
else if (size == 8 and kind == reals) array.type = &DoubleType;
else
error("can't infer type from size "s + size);
return mapTypeToPrimitive(*array.type);
Expand Down

0 comments on commit 4991f4d

Please sign in to comment.