[TypeSystem] add heap-base property to types (#431)

* support heap base in the type system

* lock around modification of status
This commit is contained in:
water111
2021-05-09 19:40:36 -04:00
committed by GitHub
parent fd3121bae5
commit 62dfa1bf07
13 changed files with 79 additions and 42 deletions
@@ -12,9 +12,10 @@
(music-volume-movie float :offset-assert 212)
(sfx-volume-movie float :offset-assert 216)
)
:heap-base #x70
:method-count-assert 30
:size-assert #xdc
:flag-assert #x1e000000dc
:flag-assert #x1e007000dc
(:methods
(dummy-20 () none 20)
(dummy-21 () none 21)
@@ -64,9 +64,10 @@
(last-time uint64 :offset-assert 152)
(voicebox uint64 :offset-assert 160)
)
:heap-base #x40
:method-count-assert 16
:size-assert #xa8
:flag-assert #x10000000a8
:flag-assert #x10004000a8
(:methods
(dummy-14 () none 14)
(dummy-15 () none 15)
@@ -78,9 +78,10 @@
(nb-of-particles int32 :offset-assert 248)
(particles hud-particle 7 :offset-assert 252)
)
:heap-base #xb0
:method-count-assert 27
:size-assert #x118
:flag-assert #x1b00000118
:flag-assert #x1b00b00118
(:methods
(dummy-14 () none 14)
(dummy-15 () none 15)
+5 -5
View File
@@ -207,10 +207,10 @@ TEST(TypeSystem, AddMethodAndLookupMethod) {
TEST(TypeSystem, NewMethod) {
TypeSystem ts;
ts.add_builtin_types();
ts.add_type("test-1", std::make_unique<BasicType>("basic", "test-1"));
ts.add_type("test-1", std::make_unique<BasicType>("basic", "test-1", false, 0));
ts.add_method(ts.lookup_type("test-1"), "new",
ts.make_function_typespec({"symbol", "string"}, "test-1"));
ts.add_type("test-2", std::make_unique<BasicType>("test-1", "test-2"));
ts.add_type("test-2", std::make_unique<BasicType>("test-1", "test-2", false, 0));
ts.add_method(ts.lookup_type("test-2"), "new",
ts.make_function_typespec({"symbol", "string", "symbol"}, "test-2"));
@@ -218,10 +218,10 @@ TEST(TypeSystem, NewMethod) {
EXPECT_EQ(ts.lookup_method("test-2", "new").type.print(),
"(function symbol string symbol test-2)");
ts.add_type("test-3", std::make_unique<BasicType>("test-1", "test-3"));
ts.add_type("test-3", std::make_unique<BasicType>("test-1", "test-3", false, 0));
EXPECT_EQ(ts.lookup_method("test-3", "new").type.print(), "(function symbol string test-1)");
ts.add_type("test-4", std::make_unique<BasicType>("test-2", "test-4"));
ts.add_type("test-4", std::make_unique<BasicType>("test-2", "test-4", false, 0));
EXPECT_EQ(ts.lookup_method("test-4", "new").type.print(),
"(function symbol string symbol test-2)");
}
@@ -229,7 +229,7 @@ TEST(TypeSystem, NewMethod) {
TEST(TypeSystem, MethodSubstitute) {
TypeSystem ts;
ts.add_builtin_types();
ts.add_type("test-1", std::make_unique<BasicType>("basic", "test-1"));
ts.add_type("test-1", std::make_unique<BasicType>("basic", "test-1", false, 0));
ts.add_method(ts.lookup_type("test-1"), "new",
ts.make_function_typespec({"symbol", "string", "_type_"}, "_type_"));