diff --git a/CMakeLists.txt b/CMakeLists.txt index 9535a4d9..939e12c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ endif () #set(VERBOSE 1) #set(DEBUG 1) #set(TRACE 1) -set(STRICT 1) #set(SDL 1) # Graphics #set(WASM 1) # no WebView, duh SET VIA TOOLCHAIN! #set(INCLUDE_MERGER 0) # include wasm_linker.cpp @@ -194,15 +193,11 @@ endif () ADD_COMPILE_FLAG("-fno-inline") # why not? debug? # ENABLE: -if (STRICT) - ADD_COMPILE_FLAG("-Wall") - ADD_COMPILE_FLAG("-Werror") # WARNINGS AS ERRORS! use -Wno-error=… for exceptions -endif () +#ADD_COMPILE_FLAG("-Werror") # WARNINGS AS ERRORS! use -Wno-error=… for exceptions ADD_COMPILE_FLAG("-Wformat") # essential !! print("%s",string) => memory corruption! ADD_COMPILE_FLAG("-Wreturn-type") # VERY USEFUL : non-void function does not return a value ADD_COMPILE_FLAG("-Wunused-result") # VERY USEFUL : check for nodiscard, e.g. in non-self-modifying replace() ADD_COMPILE_FLAG("-Wno-tautological-undefined-compare") # harmless this == 0 check -#ADD_COMPILE_FLAG("-Wno-unused-but-set-variable") if (LINUX) ADD_COMPILE_FLAG("-Wno-ambiguous-reversed-operator") ADD_COMPILE_FLAG("-Wno-writable-strings") # dangerous! fix assert_is("square 3", 9) @@ -245,6 +240,7 @@ endif () if (NOT TRACE) if (APPLE) + # ADD_COMPILE_FLAG("-Wall") # disable: if (DEBUG) if (NOT WASM) diff --git a/Makefile b/Makefile index b1b3e7f4..1041db45 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.27 +# Generated by "Unix Makefiles" Generator, CMake Version 3.22 # Default target executed when no arguments are given to make. default_target: all @@ -48,27 +48,27 @@ cmake_force: SHELL = /bin/sh # The CMake executable. -CMAKE_COMMAND = /opt/homebrew/Cellar/cmake/3.27.7/bin/cmake +CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. -RM = /opt/homebrew/Cellar/cmake/3.27.7/bin/cmake -E rm -f +RM = /usr/bin/cmake -E rm -f # Escaping for special characters. EQUALS = = # The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /Users/me/wasp +CMAKE_SOURCE_DIR = /wasp # The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /Users/me/wasp +CMAKE_BINARY_DIR = /wasp #============================================================================= # Targets provided globally by CMake. # Special rule for the target edit_cache edit_cache: - @$(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) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." + /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. .PHONY : edit_cache # Special rule for the target edit_cache @@ -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..." - /opt/homebrew/Cellar/cmake/3.27.7/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..." + /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache @@ -87,9 +87,9 @@ rebuild_cache/fast: rebuild_cache # The main all target all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /Users/me/wasp/CMakeFiles /Users/me/wasp//CMakeFiles/progress.marks + $(CMAKE_COMMAND) -E cmake_progress_start /wasp/CMakeFiles /wasp//CMakeFiles/progress.marks $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /Users/me/wasp/CMakeFiles 0 + $(CMAKE_COMMAND) -E cmake_progress_start /wasp/CMakeFiles 0 .PHONY : all # The main clean target @@ -729,30 +729,6 @@ 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 @@ -981,9 +957,6 @@ 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" diff --git a/source/Angle.cpp b/source/Angle.cpp index 74a48505..6004a6a0 100644 --- a/source/Angle.cpp +++ b/source/Angle.cpp @@ -859,7 +859,7 @@ Node &classDeclaration(Node &node, Function &function) { return dec; } -// wit type + Node &funcDeclaration(String name, Node &node, Node &body, Node *returns, Module *mod) { // if(functions.has(name)) polymorph // is_used to fake test wit signatures @@ -934,10 +934,7 @@ 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; - auto pNode = new Node("signature"); - pNode->value.data = &signature; - decl.addMeta(pNode); + decl["signature"].value.data = &signature; // function.body= &body; return decl; } @@ -1012,11 +1009,11 @@ Node &groupDeclarations(Node &expression, Function &context) { if (isType(first)) { auto fun = expression[1]; String name = fun.name; - Node &typ = first; + Node *typ = first.clone(); Node modifieres = NIL; Node &arguments = fun.values(); Node &body = expression.last(); - return groupFunctionDeclaration(name, &typ, NIL, arguments, body, context); + return groupFunctionDeclaration(name, typ, NIL, arguments, body, context); } else if (isType(first.first())) { auto fun = first[1]; String name = fun.name; diff --git a/source/Code.h b/source/Code.h index 1bfc400f..9d7e9fc4 100644 --- a/source/Code.h +++ b/source/Code.h @@ -1105,10 +1105,10 @@ class Signature { Signature &returns(Type type) { // return_type = type; if (type.kind != nils and type.kind != undefined and type.kind != unknown) { -// if (multi_value or return_types.size() == 0) + if (multi_value or return_types.size() == 0) return_types.add(type); -// else -// return_types[0] = type; + else + return_types[0] = type; #if DEBUG and not WASM debug_name += ": "; debug_name += typeName(type); diff --git a/source/Node.h b/source/Node.h index fe1914b5..c291911d 100644 --- a/source/Node.h +++ b/source/Node.h @@ -607,7 +607,6 @@ class Node { bool operator==(Node *other);// equals bool operator==(Node const *other);// equals -// bool operator==(Node const &other);// equals bool operator==(const Node &other);// equals diff --git a/source/NodeTypes.h b/source/NodeTypes.h index b5509e69..59795162 100644 --- a/source/NodeTypes.h +++ b/source/NodeTypes.h @@ -132,11 +132,9 @@ enum Valtype { // types //extern const Node DoubleType; //extern const Node LongType; -// todo const! -//extern Node const DoubleType; // FloatType RealType -extern Node DoubleType; // FloatType RealType extern Node IntegerType; // maps to int32 in external abi! don't use internally much, only for struct extern Node LongType; +extern Node DoubleType; // FloatType RealType extern Node BoolType; extern Node CodepointType;// CharType CharacterType extern Node ByteType; diff --git a/source/test_wasm.cpp b/source/test_wasm.cpp index ea0e6c1f..df5ac1f3 100644 --- a/source/test_wasm.cpp +++ b/source/test_wasm.cpp @@ -939,7 +939,6 @@ 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); diff --git a/source/tests.cpp b/source/tests.cpp index 78657de1..e191ee42 100644 --- a/source/tests.cpp +++ b/source/tests.cpp @@ -9,7 +9,6 @@ #include "Paint.h" #pragma GCC diagnostic ignored "-Wdeprecated" - #import "test_angle.cpp" #import "test_wast.cpp" #import "test_wasm.cpp" @@ -3271,17 +3270,16 @@ void testCurrent() { // ⚠️ CANNOT USE assert_emit in WASM! ONLY via testRun() // assert_emit("print('hi')", 0) // assert_emit("puts('hi')", 8) + + // exit(1); + assert_emit("(2 4 3)[1]", 4); + assert_eval("if (0) {3}", false); - 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); + testSubGroupingFlatten(); + testTypedFunctions(); testTypes(); + testPolymorphism(); // assert_emit("√3^2", 3) // testSinus(); testDom(); diff --git a/source/wasm_emitter.cpp b/source/wasm_emitter.cpp index 860f9825..bd04b012 100644 --- a/source/wasm_emitter.cpp +++ b/source/wasm_emitter.cpp @@ -1668,7 +1668,7 @@ Code emitOperator(Node &node, Function &context) { code.add(0x01); // todo: memory index argument!? if (last_type == none or last_type == voids) last_type = i32t; - if ((opcode >= 0x45 and opcode <= 0x78) or opcode == string_eq) + if (opcode >= 0x45 and opcode <= 0x78 or opcode == string_eq) last_type = i32;// int ops (also f64.eqz …) } else if (name == "²") { // error("this should be handled universally in analyse: x² => x*x no matter what!");