Skip to content

Commit

Permalink
CURRENT TESTS PASSED
Browse files Browse the repository at this point in the history
testPolymorphism OK!
  • Loading branch information
pannous committed Dec 25, 2023
1 parent 4991f4d commit d5222e7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 69 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -245,6 +240,7 @@ endif ()

if (NOT TRACE)
if (APPLE)
# ADD_COMPILE_FLAG("-Wall")
# disable:
if (DEBUG)
if (NOT WASM)
Expand Down
49 changes: 11 additions & 38 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.27
# Generated by "Unix Makefiles" Generator, CMake Version 3.22

# 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 = /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
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..."
/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
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 /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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
11 changes: 4 additions & 7 deletions source/Angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions source/Code.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion source/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 1 addition & 3 deletions source/NodeTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion source/test_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 7 additions & 9 deletions source/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "Paint.h"

#pragma GCC diagnostic ignored "-Wdeprecated"

#import "test_angle.cpp"
#import "test_wast.cpp"
#import "test_wasm.cpp"
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion source/wasm_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down

0 comments on commit d5222e7

Please sign in to comment.