mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 07:25:37 -04:00
Add enums and some cleanup (#148)
* support enums * better compiler warnings * tweaks to build with clang
This commit is contained in:
+1
-1
@@ -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))
|
||||
)
|
||||
@@ -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"});
|
||||
}
|
||||
Reference in New Issue
Block a user