support type-ref (#613)

This commit is contained in:
water111
2021-06-20 12:59:39 -04:00
committed by GitHub
parent adcb9fad55
commit 4f8403d8e6
16 changed files with 192 additions and 29 deletions
@@ -234,7 +234,7 @@
;; definition of type entity-actor
(deftype entity-actor (entity)
((nav-mesh nav-mesh :offset-assert 52)
(etype basic :offset-assert 56)
(etype type :offset-assert 56)
(task uint8 :offset-assert 60)
(vis-id uint16 :offset-assert 62)
(quat quaternion :inline :offset-assert 64)
@@ -252,9 +252,9 @@
;; definition of type entity-info
(deftype entity-info (basic)
((ptype basic :offset-assert 4)
((ptype type :offset-assert 4)
(package basic :offset-assert 8)
(art-group basic :offset-assert 12)
(art-group pair :offset-assert 12)
(pool basic :offset-assert 16)
(heap-size int32 :offset-assert 20)
)
@@ -0,0 +1,24 @@
;; define a type with fields that hold a type.
(deftype test-type-with-type-field (basic)
((name string)
(some-type-1 type)
(some-type-2 type))
)
(let ((obj (new 'static 'test-type-with-type-field
:name "test"
:some-type-2 (type-ref some-unknown-type :method-count 20)
:some-type-1 (type-ref string :method-count 9)))
(old-string string))
(format #t "~A ~A ~A ~A ~D ~D~%"
(-> obj some-type-1 symbol)
(= (-> obj some-type-1) old-string) ;; should not reallocate string
(-> obj some-type-1 parent)
(-> obj some-type-2 symbol) ;; should fill out type symbol
(-> obj some-type-2 allocated-length) ;; and method length
(-> obj some-type-2 parent) ;; but other stuff should be 0's
)
)
+6
View File
@@ -621,6 +621,12 @@ TEST_F(WithGameTests, StaticArrayField) {
"0\n"});
}
TEST_F(WithGameTests, TypeReference) {
runner.run_static_test(env, testCategory, "test-type-ref.gc",
{"string #t basic some-unknown-type 20 0\n"
"0\n"});
}
TEST_F(WithGameTests, StaticFieldInlineArray) {
runner.run_static_test(env, testCategory, "test-static-field-inline-arrays.gc",
{"\"second\" \"first\"\n"