diff --git a/CMakeLists.txt b/CMakeLists.txt index 939e12c7..0ea8a746 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") set(X86_64 1) endif () -# ⚠️ SET these configurations via CLion Preferences… Build->CMake->Profiles +# ⚠️ SET these configurations VIA TOOLCHAIN: via CLion Preferences… Build->CMake->Profiles # MANUALLY force set these only for urgent debugging #set(RELEASE 1) # no tests todo VS: #set(NO_TESTS 1) # no tests @@ -18,8 +18,9 @@ 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(WASM 1) # SET VIA TOOLCHAIN! #set(INCLUDE_MERGER 0) # include wasm_linker.cpp #set(WABT_MERGE 1) # not the whole WABT though, heavy #ADD_DEFINITIONS(-DMULTI_VALUE) # change ABI to always return (value, type) tuple @@ -193,7 +194,10 @@ endif () ADD_COMPILE_FLAG("-fno-inline") # why not? debug? # ENABLE: -#ADD_COMPILE_FLAG("-Werror") # WARNINGS AS ERRORS! use -Wno-error=… for exceptions +if (STRICT) + ADD_COMPILE_FLAG("-Wall") + ADD_COMPILE_FLAG("-Werror") # WARNINGS AS ERRORS! use -Wno-error=… for exceptions +endif () 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() diff --git a/index.html b/index.html index dbc19245..10a938c1 100644 --- a/index.html +++ b/index.html @@ -43,6 +43,9 @@

A new programming language for wasm

diff --git a/source/tests.cpp b/source/tests.cpp index e191ee42..c117fcbe 100644 --- a/source/tests.cpp +++ b/source/tests.cpp @@ -21,12 +21,21 @@ #define assert_parses(marka) result=assert_parsesx(marka);if(result==ERROR){printf("NOT PARSING %s\n",marka);backtrace_line();} -void testDom() { + +void testCanvas() { result = analyze(parse("$canvas")); assert_equals(result.kind, (int64) externref); - auto nod = eval("$canvas;123"); + auto nod = eval(" ctx = $canvas.getContext('2d');\n" + " ctx.fillStyle = 'red';\n" + " ctx.fillRect(10, 10, 150, 100);"); print(nod); +} + +void testDom() { + result = analyze(parse("$canvas")); + assert_equals(result.kind, (int64) externref); // embedder.trace('canvas = document.getElementById("canvas");') +// print(nod); } void testTypes() { @@ -668,7 +677,7 @@ void testHyphenUnits() { } void testHypenVersusMinus() { - const char *code = "a=1 b=2 b-a"; + const char *code = "a=-1 b=2 b-a"; assert_emit(code, 3); // kebab case const char *data = "a-b:2 c-d:4 a-b"; @@ -3273,15 +3282,11 @@ void testCurrent() { // exit(1); - assert_emit("(2 4 3)[1]", 4); - assert_eval("if (0) {3}", false); testSubGroupingFlatten(); testTypedFunctions(); testTypes(); testPolymorphism(); -// assert_emit("√3^2", 3) -// testSinus(); testDom(); // testKebabCase(); skip( diff --git a/source/wasm_emitter.cpp b/source/wasm_emitter.cpp index bd04b012..860f9825 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!");