mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen,ast: reduce memory usage for compiling larger V programs
This commit is contained in:
parent
2e3384aaef
commit
11bffc957a
@ -349,7 +349,7 @@ pub mut:
|
|||||||
end_comments []Comment // comments that after const field
|
end_comments []Comment // comments that after const field
|
||||||
// the comptime_expr_value field is filled by the checker, when it has enough
|
// the comptime_expr_value field is filled by the checker, when it has enough
|
||||||
// info to evaluate the constant at compile time
|
// info to evaluate the constant at compile time
|
||||||
comptime_expr_value ComptTimeConstValue = empty_comptime_const_expr()
|
comptime_expr_value ComptTimeConstValue = empty_comptime_const_expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// const declaration
|
// const declaration
|
||||||
@ -1006,9 +1006,9 @@ pub mut:
|
|||||||
or_block OrExpr
|
or_block OrExpr
|
||||||
|
|
||||||
ct_left_value_evaled bool
|
ct_left_value_evaled bool
|
||||||
ct_left_value ComptTimeConstValue = empty_comptime_const_expr()
|
ct_left_value ComptTimeConstValue = empty_comptime_const_expr
|
||||||
ct_right_value_evaled bool
|
ct_right_value_evaled bool
|
||||||
ct_right_value ComptTimeConstValue = empty_comptime_const_expr()
|
ct_right_value ComptTimeConstValue = empty_comptime_const_expr
|
||||||
|
|
||||||
before_op_comments []Comment
|
before_op_comments []Comment
|
||||||
after_op_comments []Comment
|
after_op_comments []Comment
|
||||||
|
@ -15,9 +15,7 @@ pub type ComptTimeConstValue = EmptyExpr
|
|||||||
| u8
|
| u8
|
||||||
| voidptr
|
| voidptr
|
||||||
|
|
||||||
pub fn empty_comptime_const_expr() ComptTimeConstValue {
|
pub const empty_comptime_const_expr = ComptTimeConstValue(EmptyExpr(0))
|
||||||
return EmptyExpr(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (val ComptTimeConstValue) i8() ?i8 {
|
pub fn (val ComptTimeConstValue) i8() ?i8 {
|
||||||
x := val.i64()?
|
x := val.i64()?
|
||||||
|
@ -493,7 +493,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
|||||||
concrete_types := (left_sym.info as ast.Struct).concrete_types
|
concrete_types := (left_sym.info as ast.Struct).concrete_types
|
||||||
mut method_name := left_sym.cname + '_' + util.replace_op(extracted_op)
|
mut method_name := left_sym.cname + '_' + util.replace_op(extracted_op)
|
||||||
method_name = g.generic_fn_name(concrete_types, method_name)
|
method_name = g.generic_fn_name(concrete_types, method_name)
|
||||||
g.write(' = ${method_name}(')
|
g.write(' = ')
|
||||||
|
g.write(method_name)
|
||||||
|
g.write('(')
|
||||||
g.expr(left)
|
g.expr(left)
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
g.expr(val)
|
g.expr(val)
|
||||||
@ -504,7 +506,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
|||||||
&& !left_sym.has_method(extracted_op) {
|
&& !left_sym.has_method(extracted_op) {
|
||||||
g.write(' = ')
|
g.write(' = ')
|
||||||
g.expr(left)
|
g.expr(left)
|
||||||
g.write(' ${extracted_op} ')
|
g.write(' ')
|
||||||
|
g.write(extracted_op)
|
||||||
|
g.write(' ')
|
||||||
g.expr(val)
|
g.expr(val)
|
||||||
g.write(';')
|
g.write(';')
|
||||||
return
|
return
|
||||||
@ -631,7 +635,11 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
|||||||
g.writeln(';')
|
g.writeln(';')
|
||||||
}
|
}
|
||||||
} else if !g.is_arraymap_set && !str_add && !op_overloaded {
|
} else if !g.is_arraymap_set && !str_add && !op_overloaded {
|
||||||
g.write(' ${op} ')
|
// ordinary `=` in `x = 2 * y;`
|
||||||
|
// Note, that this branch *deliberately does not use interpolation*
|
||||||
|
g.write(' ')
|
||||||
|
g.write(op.str())
|
||||||
|
g.write(' ')
|
||||||
} else if str_add || op_overloaded {
|
} else if str_add || op_overloaded {
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
}
|
}
|
||||||
|
@ -1016,7 +1016,9 @@ fn (mut g Gen) gen_is_none_check(node ast.InfixExpr) {
|
|||||||
g.write(' ')
|
g.write(' ')
|
||||||
g.write('${left_var}.state')
|
g.write('${left_var}.state')
|
||||||
}
|
}
|
||||||
g.write(' ${node.op.str()} ')
|
g.write(' ')
|
||||||
|
g.write(node.op.str())
|
||||||
|
g.write(' ')
|
||||||
g.write('2') // none state
|
g.write('2') // none state
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,7 +1032,9 @@ fn (mut g Gen) gen_plain_infix_expr(node ast.InfixExpr) {
|
|||||||
g.write('*')
|
g.write('*')
|
||||||
}
|
}
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
g.write(' ${node.op.str()} ')
|
g.write(' ')
|
||||||
|
g.write(node.op.str())
|
||||||
|
g.write(' ')
|
||||||
if node.right_type.is_ptr() && node.right.is_auto_deref_var() {
|
if node.right_type.is_ptr() && node.right.is_auto_deref_var() {
|
||||||
g.write('*')
|
g.write('*')
|
||||||
g.expr(node.right)
|
g.expr(node.right)
|
||||||
|
Loading…
Reference in New Issue
Block a user