use get_type2 in struct.v
parent
cca650c655
commit
79b26b1654
|
@ -8,7 +8,7 @@ import (
|
||||||
strings
|
strings
|
||||||
)
|
)
|
||||||
|
|
||||||
fn (p mut Parser) get_type3() Type{
|
fn (p mut Parser) get_type2() Type{
|
||||||
mut mul := false
|
mut mul := false
|
||||||
mut nr_muls := 0
|
mut nr_muls := 0
|
||||||
mut typ := ''
|
mut typ := ''
|
||||||
|
@ -189,6 +189,17 @@ fn (p mut Parser) get_type3() Type{
|
||||||
typ = 'Option_$typ'
|
typ = 'Option_$typ'
|
||||||
p.table.register_type_with_parent(typ, 'Option')
|
p.table.register_type_with_parent(typ, 'Option')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Because the code uses * to see if it's a pointer
|
||||||
|
if typ == 'byteptr' {
|
||||||
|
typ = 'byte*'
|
||||||
|
}
|
||||||
|
if typ == 'voidptr' {
|
||||||
|
//if !p.builtin_mod && p.mod != 'os' && p.mod != 'gx' && p.mod != 'gg' && !p.pref.translated {
|
||||||
|
//p.error('voidptr can only be used in unsafe code')
|
||||||
|
//}
|
||||||
|
typ = 'void*'
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
TODO this is not needed?
|
TODO this is not needed?
|
||||||
if typ.last_index('__') > typ.index('__') {
|
if typ.last_index('__') > typ.index('__') {
|
||||||
|
|
|
@ -740,7 +740,7 @@ fn (p mut Parser) type_decl() {
|
||||||
if p.tok == .key_struct {
|
if p.tok == .key_struct {
|
||||||
p.error('use `struct $name {` instead of `type $name struct {`')
|
p.error('use `struct $name {` instead of `type $name struct {`')
|
||||||
}
|
}
|
||||||
parent := p.get_type3()
|
parent := p.get_type2()
|
||||||
nt_pair := p.table.cgen_name_type_pair(name, parent.name)
|
nt_pair := p.table.cgen_name_type_pair(name, parent.name)
|
||||||
// TODO dirty C typedef hacks for DOOM
|
// TODO dirty C typedef hacks for DOOM
|
||||||
// Unknown type probably means it's a struct, and it's used before the struct is defined,
|
// Unknown type probably means it's a struct, and it's used before the struct is defined,
|
||||||
|
|
|
@ -194,9 +194,10 @@ fn (p mut Parser) struct_decl() {
|
||||||
// `pub` access mod
|
// `pub` access mod
|
||||||
access_mod := if is_pub_field { AccessMod.public } else { AccessMod.private}
|
access_mod := if is_pub_field { AccessMod.public } else { AccessMod.private}
|
||||||
p.fspace()
|
p.fspace()
|
||||||
field_type := p.get_type()
|
tt := p.get_type2()
|
||||||
|
field_type := tt.name
|
||||||
if field_type == name {
|
if field_type == name {
|
||||||
p.error_with_token_index( 'cannot embed struct `$name` in itself (field `$field_name`)', field_name_token_idx)
|
p.error_with_token_index('cannot embed struct `$name` in itself (field `$field_name`)', field_name_token_idx)
|
||||||
}
|
}
|
||||||
// Register ?option type
|
// Register ?option type
|
||||||
if field_type.starts_with('Option_') {
|
if field_type.starts_with('Option_') {
|
||||||
|
|
Loading…
Reference in New Issue