Skip to content

Commit

Permalink
Add type constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Dec 16, 2024
1 parent fda437d commit 385707c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion std/reflection.pr
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ export type TupleT = &struct {
elements: &[weak Type]
}

export type TypeConstructorT = &struct {
BaseType
const size: size_t = 0
const align: size_t = 0
}

type TypeKind = enum {
BOOL
WORD
Expand All @@ -197,6 +203,7 @@ type TypeKind = enum {
VARIANT
TUPLE
TYPE
TYPE_CONSTRUCTOR
OPAQUE // Same as STUB in typechecking
}

Expand Down Expand Up @@ -233,7 +240,7 @@ def load_types(input: *uint8, size: size_t, num: size_t, strings: *char) {
new_types.push(id)

//NOTE: print doesn't work in here
printf("%d %s %s %zu\n".value, kind, name.data ++ name.offset, module.data ++ module.offset, id)
printf("%d %s %s %zd\n".value, kind, name.data ++ name.offset, module.data ++ module.offset, id)

switch kind {
case TypeKind::BOOL
Expand Down Expand Up @@ -336,6 +343,8 @@ def load_types(input: *uint8, size: size_t, num: size_t, strings: *char) {
types(id) = [ name = name, module = module, id = id ] !TypeT
case TypeKind::OPAQUE
types(id) = [ name = name, module = module, id = id ] !OpaqueT
case TypeKind::TYPE_CONSTRUCTOR
types(id) = [ name = name, module = module, id = id ] !TypeConstructorT
}

index += 1
Expand All @@ -345,6 +354,7 @@ def load_types(input: *uint8, size: size_t, num: size_t, strings: *char) {

// Resolve type references
for var id in new_types {
printf("%zd\n".value, id)
let tpe = types(id)

let base = *(tpe !BaseType)
Expand Down

0 comments on commit 385707c

Please sign in to comment.