1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: fix struct order bug

This commit is contained in:
Alexander Medvednikov
2019-08-29 01:52:32 +03:00
parent c6b79dfd24
commit 2fe20cd092
4 changed files with 199 additions and 156 deletions

View File

@ -7,29 +7,6 @@ module main
import math
import strings
struct Var {
mut:
typ string
name string
is_arg bool
is_const bool
args []Var // function args
attr string // [json] etc
is_mut bool
is_alloc bool
ptr bool
ref bool
parent_fn string // Variables can only be defined in functions
mod string // module where this var is stored
line_nr int
access_mod AccessMod
is_global bool // __global (translated from C only)
is_used bool
is_changed bool
scope_level int
}
struct Table {
mut:
types []Type
@ -45,6 +22,9 @@ mut:
obfuscate bool
}
struct GenTable {
fn_name string
types []string
@ -77,6 +57,30 @@ enum TypeCategory {
c_typedef
}
struct Var {
mut:
typ string
name string
is_arg bool
is_const bool
args []Var // function args
attr string // [json] etc
is_mut bool
is_alloc bool
ptr bool
ref bool
parent_fn string // Variables can only be defined in functions
mod string // module where this var is stored
line_nr int
access_mod AccessMod
is_global bool // __global (translated from C only)
is_used bool
is_changed bool
scope_level int
}
struct Type {
mut:
mod string
@ -96,6 +100,13 @@ mut:
gen_str bool // needs `.str()` method generation
}
struct TypeNode {
mut:
next &TypeNode
typ Type
}
// For debugging types
fn (t Type) str() string {
mut s := 'type "$t.name" {'
@ -928,6 +939,9 @@ fn (fit &FileImportTable) resolve_alias(alias string) string {
}
fn (t &Type) contains_field_type(typ string) bool {
if !t.name[0].is_capital() {
return false
}
for field in t.fields {
if field.typ == typ {
return true