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

all: use the new types with old syntax (#6922)

This commit is contained in:
Daniel Däschle
2020-11-24 13:58:29 +01:00
committed by GitHub
parent 8be9bdacd1
commit aa6303f0b2
22 changed files with 303 additions and 300 deletions

View File

@ -73,8 +73,8 @@ pub fn (s &Scope) is_known(name string) bool {
pub fn (s &Scope) find_var(name string) ?&Var {
if obj := s.find(name) {
match obj {
Var { return obj }
match union obj {
Var { return &obj }
else {}
}
}
@ -83,8 +83,8 @@ pub fn (s &Scope) find_var(name string) ?&Var {
pub fn (s &Scope) find_const(name string) ?&ConstField {
if obj := s.find(name) {
match obj {
ConstField { return obj }
match union obj {
ConstField { return &obj }
else {}
}
}
@ -100,12 +100,13 @@ pub fn (s &Scope) known_var(name string) bool {
pub fn (mut s Scope) update_var_type(name string, typ table.Type) {
s.end_pos = s.end_pos // TODO mut bug
match mut s.objects[name] {
mut obj := s.objects[name]
match union mut obj {
Var {
if it.typ == typ {
if obj.typ == typ {
return
}
it.typ = typ
obj.typ = typ
}
else {}
}
@ -181,7 +182,7 @@ pub fn (sc &Scope) show(depth int, max_depth int) string {
}
out += '$indent# $sc.start_pos - $sc.end_pos\n'
for _, obj in sc.objects {
match obj {
match union obj {
ConstField { out += '$indent * const: $obj.name - $obj.typ\n' }
Var { out += '$indent * var: $obj.name - $obj.typ\n' }
else {}