function calls
This commit is contained in:
15
generator.v
15
generator.v
@@ -17,7 +17,7 @@ fn (mut g Generator) gen_stmt(stmt Stmt) {
|
||||
match stmt {
|
||||
VarDecl {
|
||||
c_type := g.get_c_type(stmt.type)
|
||||
g.out.write_string('${c_type} ${stmt.name} = ')
|
||||
g.out.write_string('${c_type} v${stmt.name}${stmt.scope_depth.str()} = ')
|
||||
g.gen_expr(stmt.value)
|
||||
g.out.writeln(';')
|
||||
}
|
||||
@@ -57,10 +57,9 @@ fn (mut g Generator) gen_expr(expr Expr) {
|
||||
g.out.write_string(expr.val.str())
|
||||
}
|
||||
Variable {
|
||||
g.out.write_string(expr.name)
|
||||
g.out.write_string('v${expr.name}${expr.scope_depth.str()}')
|
||||
}
|
||||
UnaryExpr {
|
||||
// Handle postfix/prefix logic if necessary
|
||||
g.out.write_string('${expr.ident}${expr.op}')
|
||||
}
|
||||
BinaryExpr {
|
||||
@@ -86,7 +85,15 @@ fn (mut g Generator) gen_expr(expr Expr) {
|
||||
g.out.write_string('(${c_type})')
|
||||
g.gen_expr(expr.expr)
|
||||
}
|
||||
else {panic('unimplemented ${expr}')}
|
||||
ParenExpr {
|
||||
g.out.write_string('(')
|
||||
g.gen_expr(expr.expr)
|
||||
g.out.write_string(')')
|
||||
}
|
||||
FnCall {
|
||||
g.out.write_string('${expr.name}()')
|
||||
}
|
||||
else {panic("Unimplemented expression")}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user