cgen: fix ->
parent
f5a8d883d2
commit
c14c81ace6
|
@ -68,6 +68,8 @@ pub:
|
|||
pos token.Position
|
||||
expr Expr
|
||||
field string
|
||||
mut:
|
||||
expr_type table.Type
|
||||
}
|
||||
|
||||
// module declaration
|
||||
|
@ -279,7 +281,7 @@ pub:
|
|||
pos token.Position
|
||||
left Expr
|
||||
right Expr
|
||||
mut:
|
||||
mut:
|
||||
left_type table.Type
|
||||
right_type table.Type
|
||||
}
|
||||
|
|
|
@ -296,8 +296,9 @@ pub fn (c mut Checker) method_call_expr(method_call_expr mut ast.MethodCallExpr)
|
|||
return table.void_type
|
||||
}
|
||||
|
||||
pub fn (c mut Checker) selector_expr(selector_expr ast.SelectorExpr) table.Type {
|
||||
pub fn (c mut Checker) selector_expr(selector_expr mut ast.SelectorExpr) table.Type {
|
||||
typ := c.expr(selector_expr.expr)
|
||||
selector_expr.expr_type = typ
|
||||
typ_sym := c.table.get_type_symbol(typ)
|
||||
field_name := selector_expr.field
|
||||
if field := typ_sym.find_field(field_name) {
|
||||
|
@ -598,7 +599,7 @@ pub fn (c mut Checker) expr(node ast.Expr) table.Type {
|
|||
return c.expr(it.expr)
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
return c.selector_expr(it)
|
||||
return c.selector_expr(mut it)
|
||||
}
|
||||
ast.SizeOf {
|
||||
return table.int_type
|
||||
|
|
|
@ -310,6 +310,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
if it.is_method {
|
||||
styp := g.typ(it.receiver.typ)
|
||||
g.write('$styp $it.receiver.name')
|
||||
// TODO mut
|
||||
g.definitions.write('$styp $it.receiver.name')
|
||||
if it.args.len > 0 {
|
||||
g.write(', ')
|
||||
|
@ -347,6 +348,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
g.definitions.writeln(');')
|
||||
}
|
||||
for stmt in it.stmts {
|
||||
// g.write('\t')
|
||||
g.stmt(stmt)
|
||||
}
|
||||
if is_main {
|
||||
|
@ -609,7 +611,12 @@ fn (g mut Gen) expr(node ast.Expr) {
|
|||
}
|
||||
ast.SelectorExpr {
|
||||
g.expr(it.expr)
|
||||
if table.type_nr_muls(it.expr_type) > 0 {
|
||||
g.write('->')
|
||||
}
|
||||
else {
|
||||
g.write('.')
|
||||
}
|
||||
g.write(it.field)
|
||||
}
|
||||
ast.Type {
|
||||
|
|
Loading…
Reference in New Issue