Add enums and some cleanup (#148)

* support enums

* better compiler warnings

* tweaks to build with clang
This commit is contained in:
water111
2020-12-02 19:51:42 -05:00
committed by GitHub
parent 71dda76e2b
commit ea479bee98
24 changed files with 257 additions and 182 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ ELSE()
target_link_libraries(goalc-test cross_sockets goos common_util runtime compiler type_system gtest Zydis)
ENDIF()
if(CMAKE_COMPILER_IS_GNUCXX AND CODE_COVERAGE)
if(UNIX AND CODE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(NAME goalc-test_coverage
@@ -0,0 +1,16 @@
(defenum test-bitfield :bitfield #t
(four 2)
(one 0)
(two 1)
)
(deftype type-with-bitfield (basic)
((name basic)
(thing int32)
)
)
(let ((obj (new 'global 'type-with-bitfield)))
(set! (-> obj thing) (test-bitfield one four))
(the uint (-> obj thing))
)
@@ -0,0 +1,19 @@
(defenum test-int-enum :bitfield #f
(four 4)
(one 1)
(seven 7)
(two 2)
)
(deftype type-with-bitfield2 (basic)
((name basic)
(thing1 int32)
(thing2 int32)
)
)
(let ((obj (new 'global 'type-with-bitfield2)))
(set! (-> obj thing1) (test-int-enum four))
(set! (-> obj thing2) (test-int-enum seven))
(+ (-> obj thing1) (-> obj thing2))
)
+5
View File
@@ -72,4 +72,9 @@ TEST_F(VariableTests, Let) {
TEST_F(VariableTests, StackVars) {
runner.run_static_test(env, testCategory, "stack-ints.gc", {"12\n"});
runner.run_static_test(env, testCategory, "stack-ints-2.gc", {"1\n"});
}
TEST_F(VariableTests, Bitfields) {
runner.run_static_test(env, testCategory, "bitfield-enums.gc", {"5\n"});
runner.run_static_test(env, testCategory, "integer-enums.gc", {"11\n"});
}