v: fixes for `v -autofree -o v2 cmd/v`
parent
64d0006ff9
commit
69f1e7c9c3
|
@ -4,8 +4,8 @@
|
||||||
module builtin
|
module builtin
|
||||||
|
|
||||||
__global (
|
__global (
|
||||||
g_m2_buf byteptr
|
g_m2_buf byteptr
|
||||||
g_m2_ptr byteptr
|
g_m2_ptr byteptr
|
||||||
)
|
)
|
||||||
|
|
||||||
// isnil returns true if an object is nil (only for C objects).
|
// isnil returns true if an object is nil (only for C objects).
|
||||||
|
@ -38,19 +38,19 @@ __global (
|
||||||
total_m = i64(0)
|
total_m = i64(0)
|
||||||
nr_mallocs = int(0)
|
nr_mallocs = int(0)
|
||||||
// will be filled in cgen
|
// will be filled in cgen
|
||||||
as_cast_type_indexes []VCastTypeIndexName
|
as_cast_type_indexes []VCastTypeIndexName
|
||||||
)
|
)
|
||||||
|
|
||||||
fn __as_cast(obj voidptr, obj_type int, expected_type int) voidptr {
|
fn __as_cast(obj voidptr, obj_type int, expected_type int) voidptr {
|
||||||
if obj_type != expected_type {
|
if obj_type != expected_type {
|
||||||
mut obj_name := as_cast_type_indexes[0].tname
|
mut obj_name := as_cast_type_indexes[0].tname.clone()
|
||||||
mut expected_name := as_cast_type_indexes[0].tname
|
mut expected_name := as_cast_type_indexes[0].tname.clone()
|
||||||
for x in as_cast_type_indexes {
|
for x in as_cast_type_indexes {
|
||||||
if x.tindex == obj_type {
|
if x.tindex == obj_type {
|
||||||
obj_name = x.tname
|
obj_name = x.tname.clone()
|
||||||
}
|
}
|
||||||
if x.tindex == expected_type {
|
if x.tindex == expected_type {
|
||||||
expected_name = x.tname
|
expected_name = x.tname.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic('as cast: cannot cast `$obj_name` to `$expected_name`')
|
panic('as cast: cannot cast `$obj_name` to `$expected_name`')
|
||||||
|
|
|
@ -408,9 +408,7 @@ pub fn (node Stmt) str() string {
|
||||||
return node.str()
|
return node.str()
|
||||||
}
|
}
|
||||||
ConstDecl {
|
ConstDecl {
|
||||||
fields := node.fields.map(fn (f ConstField) string {
|
fields := node.fields.map(field_to_string)
|
||||||
return '${f.name.trim_prefix(f.mod + '.')} = $f.expr'
|
|
||||||
})
|
|
||||||
return 'const (${fields.join(' ')})'
|
return 'const (${fields.join(' ')})'
|
||||||
}
|
}
|
||||||
ExprStmt {
|
ExprStmt {
|
||||||
|
@ -441,6 +439,10 @@ pub fn (node Stmt) str() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn field_to_string(f ConstField) string {
|
||||||
|
return '${f.name.trim_prefix(f.mod + '.')} = $f.expr'
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (e CompForKind) str() string {
|
pub fn (e CompForKind) str() string {
|
||||||
match e {
|
match e {
|
||||||
.methods { return 'methods' }
|
.methods { return 'methods' }
|
||||||
|
|
|
@ -285,7 +285,9 @@ pub fn (b &Builder) find_module_path(mod string, fpath string) ?string {
|
||||||
|
|
||||||
fn (b &Builder) show_total_warns_and_errors_stats() {
|
fn (b &Builder) show_total_warns_and_errors_stats() {
|
||||||
if b.pref.is_stats {
|
if b.pref.is_stats {
|
||||||
println('checker summary: ${util.bold(b.checker.nr_errors.str())} V errors, ${util.bold(b.checker.nr_warnings.str())} V warnings')
|
estring := util.bold(b.checker.nr_errors.str())
|
||||||
|
wstring := util.bold(b.checker.nr_warnings.str())
|
||||||
|
println('checker summary: $estring V errors, $wstring V warnings')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ pub fn (mut b Builder) build_c(v_files []string, out_file string) {
|
||||||
f.writeln(output2) or { panic(err) }
|
f.writeln(output2) or { panic(err) }
|
||||||
f.close()
|
f.close()
|
||||||
if b.pref.is_stats {
|
if b.pref.is_stats {
|
||||||
println('generated C source code size: ${util.bold((output2.count('\n') + 1).str())} lines, ${util.bold(output2.len.str())} bytes')
|
slines := util.bold((output2.count('\n') + 1).str())
|
||||||
|
sbytes := util.bold(output2.len.str())
|
||||||
|
println('generated C source code size: $slines lines, $sbytes bytes')
|
||||||
}
|
}
|
||||||
// os.write_file(out_file, b.gen_c(v_files))
|
// os.write_file(out_file, b.gen_c(v_files))
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ fn (mut b Builder) get_vtmp_filename(base_file_name string, postfix string) stri
|
||||||
if !b.pref.reuse_tmpc {
|
if !b.pref.reuse_tmpc {
|
||||||
uniq = '.$rand.u64()'
|
uniq = '.$rand.u64()'
|
||||||
}
|
}
|
||||||
return os.real_path(os.join_path(vtmp, os.file_name(os.real_path(base_file_name)) +
|
fname := os.file_name(os.real_path(base_file_name)) + '$uniq$postfix'
|
||||||
'$uniq$postfix'))
|
return os.real_path(os.join_path(vtmp, fname))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile(command string, pref &pref.Preferences) {
|
pub fn compile(command string, pref &pref.Preferences) {
|
||||||
|
@ -45,7 +45,8 @@ pub fn compile(command string, pref &pref.Preferences) {
|
||||||
.x64 { b.compile_x64() }
|
.x64 { b.compile_x64() }
|
||||||
}
|
}
|
||||||
if pref.is_stats {
|
if pref.is_stats {
|
||||||
println('compilation took: ${util.bold(sw.elapsed().milliseconds().str())} ms')
|
compilation_time := util.bold(sw.elapsed().milliseconds().str())
|
||||||
|
println('compilation took: $compilation_time ms')
|
||||||
}
|
}
|
||||||
b.exit_on_invalid_syntax()
|
b.exit_on_invalid_syntax()
|
||||||
// running does not require the parsers anymore
|
// running does not require the parsers anymore
|
||||||
|
|
|
@ -58,12 +58,16 @@ fn (mut g Gen) gen_assert_metainfo(node ast.AssertStmt) string {
|
||||||
g.writeln('\t${metaname}.fpath = ${ctoslit(mod_path)};')
|
g.writeln('\t${metaname}.fpath = ${ctoslit(mod_path)};')
|
||||||
g.writeln('\t${metaname}.line_nr = $line_nr;')
|
g.writeln('\t${metaname}.line_nr = $line_nr;')
|
||||||
g.writeln('\t${metaname}.fn_name = ${ctoslit(fn_name)};')
|
g.writeln('\t${metaname}.fn_name = ${ctoslit(fn_name)};')
|
||||||
g.writeln('\t${metaname}.src = ${cnewlines(ctoslit(src))};')
|
metasrc := cnewlines(ctoslit(src))
|
||||||
|
g.writeln('\t${metaname}.src = $metasrc;')
|
||||||
match mut node.expr {
|
match mut node.expr {
|
||||||
ast.InfixExpr {
|
ast.InfixExpr {
|
||||||
g.writeln('\t${metaname}.op = ${ctoslit(node.expr.op.str())};')
|
expr_op_str := ctoslit(node.expr.op.str())
|
||||||
g.writeln('\t${metaname}.llabel = ${cnewlines(ctoslit(node.expr.left.str()))};')
|
expr_left_str := cnewlines(ctoslit(node.expr.left.str()))
|
||||||
g.writeln('\t${metaname}.rlabel = ${cnewlines(ctoslit(node.expr.right.str()))};')
|
expr_right_str := cnewlines(ctoslit(node.expr.right.str()))
|
||||||
|
g.writeln('\t${metaname}.op = $expr_op_str;')
|
||||||
|
g.writeln('\t${metaname}.llabel = $expr_left_str;')
|
||||||
|
g.writeln('\t${metaname}.rlabel = $expr_right_str;')
|
||||||
g.write('\t${metaname}.lvalue = ')
|
g.write('\t${metaname}.lvalue = ')
|
||||||
g.gen_assert_single_expr(node.expr.left, node.expr.left_type)
|
g.gen_assert_single_expr(node.expr.left, node.expr.left_type)
|
||||||
g.writeln(';')
|
g.writeln(';')
|
||||||
|
|
|
@ -737,10 +737,13 @@ pub fn (mut g Gen) write_typedef_types() {
|
||||||
if parent.info is table.Struct {
|
if parent.info is table.Struct {
|
||||||
is_typedef = parent.info.is_typedef
|
is_typedef = parent.info.is_typedef
|
||||||
}
|
}
|
||||||
parent_styp := if is_c_parent {
|
mut parent_styp := parent.cname
|
||||||
if !is_typedef { 'struct ' + parent.cname[3..] } else { parent.cname[3..] }
|
if is_c_parent {
|
||||||
} else {
|
if !is_typedef {
|
||||||
parent.cname
|
parent_styp = 'struct ' + parent.cname[3..]
|
||||||
|
} else {
|
||||||
|
parent_styp = parent.cname[3..]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.type_definitions.writeln('typedef $parent_styp $typ.cname;')
|
g.type_definitions.writeln('typedef $parent_styp $typ.cname;')
|
||||||
}
|
}
|
||||||
|
@ -1375,8 +1378,9 @@ fn (mut g Gen) for_in_stmt(node ast.ForInStmt) {
|
||||||
g.writeln(';')
|
g.writeln(';')
|
||||||
}
|
}
|
||||||
i := if node.key_var in ['', '_'] { g.new_tmp_var() } else { node.key_var }
|
i := if node.key_var in ['', '_'] { g.new_tmp_var() } else { node.key_var }
|
||||||
op_field := if node.cond_type.is_ptr() { '->' } else { '.' } +
|
field_accessor := if node.cond_type.is_ptr() { '->' } else { '.' }
|
||||||
if node.cond_type.share() == .shared_t { 'val.' } else { '' }
|
share_accessor := if node.cond_type.share() == .shared_t { 'val.' } else { '' }
|
||||||
|
op_field := field_accessor + share_accessor
|
||||||
g.empty_line = true
|
g.empty_line = true
|
||||||
g.writeln('for (int $i = 0; $i < $cond_var${op_field}len; ++$i) {')
|
g.writeln('for (int $i = 0; $i < $cond_var${op_field}len; ++$i) {')
|
||||||
if node.val_var != '_' {
|
if node.val_var != '_' {
|
||||||
|
@ -3454,7 +3458,8 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
||||||
e := right_sym.kind !in [.voidptr, .int_literal, .int]
|
e := right_sym.kind !in [.voidptr, .int_literal, .int]
|
||||||
if node.op in [.plus, .minus, .mul, .div, .mod, .lt, .eq] && ((a && b && e) || c || d) {
|
if node.op in [.plus, .minus, .mul, .div, .mod, .lt, .eq] && ((a && b && e) || c || d) {
|
||||||
// Overloaded operators
|
// Overloaded operators
|
||||||
g.write(g.typ(if !d { left_type } else { (left_sym.info as table.Alias).parent_type }))
|
the_left_type := if !d { left_type } else { (left_sym.info as table.Alias).parent_type }
|
||||||
|
g.write(g.typ(the_left_type))
|
||||||
g.write('_')
|
g.write('_')
|
||||||
g.write(util.replace_op(node.op.str()))
|
g.write(util.replace_op(node.op.str()))
|
||||||
g.write('(')
|
g.write('(')
|
||||||
|
@ -3463,7 +3468,8 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
||||||
g.expr(node.right)
|
g.expr(node.right)
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else if node.op in [.ne, .gt, .ge, .le] && ((a && b && e) || c || d) {
|
} else if node.op in [.ne, .gt, .ge, .le] && ((a && b && e) || c || d) {
|
||||||
typ := g.typ(if !d { left_type } else { (left_sym.info as table.Alias).parent_type })
|
the_left_type := if !d { left_type } else { (left_sym.info as table.Alias).parent_type }
|
||||||
|
typ := g.typ(the_left_type)
|
||||||
if node.op == .gt {
|
if node.op == .gt {
|
||||||
g.write('$typ')
|
g.write('$typ')
|
||||||
} else {
|
} else {
|
||||||
|
@ -3987,7 +3993,11 @@ fn (mut g Gen) select_expr(node ast.SelectExpr) {
|
||||||
objs_array := g.new_tmp_var()
|
objs_array := g.new_tmp_var()
|
||||||
g.write('Array_voidptr $objs_array = new_array_from_c_array($n_channels, $n_channels, sizeof(voidptr), _MOV((voidptr[$n_channels]){')
|
g.write('Array_voidptr $objs_array = new_array_from_c_array($n_channels, $n_channels, sizeof(voidptr), _MOV((voidptr[$n_channels]){')
|
||||||
for i in 0 .. n_channels {
|
for i in 0 .. n_channels {
|
||||||
g.write(if i > 0 { ', &' } else { '&' })
|
if i > 0 {
|
||||||
|
g.write(', &')
|
||||||
|
} else {
|
||||||
|
g.write('&')
|
||||||
|
}
|
||||||
if tmp_objs[i] == '' {
|
if tmp_objs[i] == '' {
|
||||||
g.expr(objs[i])
|
g.expr(objs[i])
|
||||||
} else {
|
} else {
|
||||||
|
@ -5574,11 +5584,12 @@ fn (mut g Gen) go_stmt(node ast.GoStmt, joinable bool) string {
|
||||||
g.writeln('$arg_tmp_var->ret_ptr = malloc(sizeof($s_ret_typ));')
|
g.writeln('$arg_tmp_var->ret_ptr = malloc(sizeof($s_ret_typ));')
|
||||||
}
|
}
|
||||||
is_opt := node.call_expr.return_type.has_flag(.optional)
|
is_opt := node.call_expr.return_type.has_flag(.optional)
|
||||||
gohandle_name := if node.call_expr.return_type == table.void_type {
|
mut gohandle_name := ''
|
||||||
if is_opt { '__v_thread_Option_void' } else { '__v_thread' }
|
if node.call_expr.return_type == table.void_type {
|
||||||
|
gohandle_name = if is_opt { '__v_thread_Option_void' } else { '__v_thread' }
|
||||||
} else {
|
} else {
|
||||||
opt := if is_opt { 'Option_' } else { '' }
|
opt := if is_opt { 'Option_' } else { '' }
|
||||||
'__v_thread_$opt${g.table.get_type_symbol(g.unwrap_generic(node.call_expr.return_type)).cname}'
|
gohandle_name = '__v_thread_$opt${g.table.get_type_symbol(g.unwrap_generic(node.call_expr.return_type)).cname}'
|
||||||
}
|
}
|
||||||
if g.pref.os == .windows {
|
if g.pref.os == .windows {
|
||||||
simple_handle := if joinable && node.call_expr.return_type != table.void_type {
|
simple_handle := if joinable && node.call_expr.return_type != table.void_type {
|
||||||
|
|
|
@ -127,7 +127,8 @@ fn (mut g Gen) gen_fn_decl(node ast.FnDecl, skip bool) {
|
||||||
for gen_types in g.table.fn_gen_types[node.name] {
|
for gen_types in g.table.fn_gen_types[node.name] {
|
||||||
if g.pref.is_verbose {
|
if g.pref.is_verbose {
|
||||||
syms := gen_types.map(g.table.get_type_symbol(it))
|
syms := gen_types.map(g.table.get_type_symbol(it))
|
||||||
println('gen fn `$node.name` for type `${syms.map(node.name).join(', ')}`')
|
the_type := syms.map(node.name).join(', ')
|
||||||
|
println('gen fn `$node.name` for type `$the_type`')
|
||||||
}
|
}
|
||||||
g.cur_generic_types = gen_types
|
g.cur_generic_types = gen_types
|
||||||
g.gen_fn_decl(node, skip)
|
g.gen_fn_decl(node, skip)
|
||||||
|
|
|
@ -402,7 +402,8 @@ fn (mut g Gen) expr_to_sql(expr ast.Expr, typ SqlType) {
|
||||||
// true/false literals were added to Sqlite 3.23 (2018-04-02)
|
// true/false literals were added to Sqlite 3.23 (2018-04-02)
|
||||||
// but lots of apps/distros use older sqlite (e.g. Ubuntu 18.04 LTS )
|
// but lots of apps/distros use older sqlite (e.g. Ubuntu 18.04 LTS )
|
||||||
g.inc_sql_i()
|
g.inc_sql_i()
|
||||||
g.sql_bind_int(if expr.val { '1' } else { '0' }, typ)
|
eval := if expr.val { '1' } else { '0' }
|
||||||
|
g.sql_bind_int(eval, typ)
|
||||||
}
|
}
|
||||||
ast.Ident {
|
ast.Ident {
|
||||||
// `name == user_name` => `name == ?1`
|
// `name == user_name` => `name == ?1`
|
||||||
|
|
|
@ -690,8 +690,9 @@ fn (mut g JsGen) gen_assign_stmt(stmt ast.AssignStmt) {
|
||||||
} else {
|
} else {
|
||||||
g.write(' $op ')
|
g.write(' $op ')
|
||||||
// TODO: Multiple types??
|
// TODO: Multiple types??
|
||||||
should_cast := (g.table.type_kind(stmt.left_types.first()) in shallow_equatables)
|
should_cast :=
|
||||||
&& (g.cast_stack.len <= 0 || stmt.left_types.first() != g.cast_stack.last())
|
(g.table.type_kind(stmt.left_types.first()) in js.shallow_equatables)
|
||||||
|
&& (g.cast_stack.len <= 0 || stmt.left_types.first() != g.cast_stack.last())
|
||||||
|
|
||||||
if should_cast {
|
if should_cast {
|
||||||
g.cast_stack << stmt.left_types.first()
|
g.cast_stack << stmt.left_types.first()
|
||||||
|
@ -929,26 +930,28 @@ fn (mut g JsGen) gen_for_in_stmt(it ast.ForInStmt) {
|
||||||
if it.kind == .string {
|
if it.kind == .string {
|
||||||
g.write('Array.from(')
|
g.write('Array.from(')
|
||||||
g.expr(it.cond)
|
g.expr(it.cond)
|
||||||
g.write('.str.split(\'\').entries(), ([$it.key_var, $val]) => [$it.key_var, ')
|
g.write(".str.split(\'\').entries(), ([$it.key_var, $val]) => [$it.key_var, ")
|
||||||
if g.ns.name == 'builtin' { g.write('new ') }
|
if g.ns.name == 'builtin' {
|
||||||
|
g.write('new ')
|
||||||
|
}
|
||||||
g.write('byte($val)])')
|
g.write('byte($val)])')
|
||||||
} else {
|
} else {
|
||||||
g.expr(it.cond)
|
g.expr(it.cond)
|
||||||
g.write('.entries()')
|
g.write('.entries()')
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
g.write('for (const $val of ')
|
g.write('for (const $val of ')
|
||||||
g.expr(it.cond)
|
g.expr(it.cond)
|
||||||
if it.kind == .string {
|
if it.kind == .string {
|
||||||
g.write('.str.split(\'\')')
|
g.write(".str.split('')")
|
||||||
}
|
}
|
||||||
// cast characters to bytes
|
// cast characters to bytes
|
||||||
if val !in ['', '_'] && it.kind == .string {
|
if val !in ['', '_'] && it.kind == .string {
|
||||||
g.write('.map(c => ')
|
g.write('.map(c => ')
|
||||||
if g.ns.name == 'builtin' { g.write('new ') }
|
if g.ns.name == 'builtin' {
|
||||||
|
g.write('new ')
|
||||||
|
}
|
||||||
g.write('byte(c))')
|
g.write('byte(c))')
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.writeln(') {')
|
g.writeln(') {')
|
||||||
|
@ -1089,7 +1092,11 @@ fn (mut g JsGen) gen_struct_decl(node ast.StructDecl) {
|
||||||
g.inc_indent()
|
g.inc_indent()
|
||||||
g.write('return `$js_name {')
|
g.write('return `$js_name {')
|
||||||
for i, field in node.fields {
|
for i, field in node.fields {
|
||||||
g.write(if i == 0 { ' ' } else { ', ' })
|
if i == 0 {
|
||||||
|
g.write(' ')
|
||||||
|
} else {
|
||||||
|
g.write(', ')
|
||||||
|
}
|
||||||
match g.typ(field.typ).split('.').last() {
|
match g.typ(field.typ).split('.').last() {
|
||||||
'string' { g.write('$field.name: "\${this["$field.name"].toString()}"') }
|
'string' { g.write('$field.name: "\${this["$field.name"].toString()}"') }
|
||||||
else { g.write('$field.name: \${this["$field.name"].toString()} ') }
|
else { g.write('$field.name: \${this["$field.name"].toString()} ') }
|
||||||
|
@ -1417,13 +1424,13 @@ fn (mut g JsGen) gen_infix_expr(it ast.InfixExpr) {
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else if r_sym.kind in [.array, .map, .string] && it.op in [.key_in, .not_in] {
|
} else if r_sym.kind in [.array, .map, .string] && it.op in [.key_in, .not_in] {
|
||||||
g.expr(it.right)
|
g.expr(it.right)
|
||||||
g.write(if r_sym.kind == .map {
|
if r_sym.kind == .map {
|
||||||
'.has('
|
g.write('.has(')
|
||||||
} else if r_sym.kind == .string {
|
} else if r_sym.kind == .string {
|
||||||
'.str.includes('
|
g.write('.str.includes(')
|
||||||
} else {
|
} else {
|
||||||
'.includes('
|
g.write('.includes(')
|
||||||
})
|
}
|
||||||
g.expr(it.left)
|
g.expr(it.left)
|
||||||
if l_sym.kind == .string {
|
if l_sym.kind == .string {
|
||||||
g.write('.str')
|
g.write('.str')
|
||||||
|
@ -1443,7 +1450,7 @@ fn (mut g JsGen) gen_infix_expr(it ast.InfixExpr) {
|
||||||
needs_cast = g.cast_stack.last() != greater_typ
|
needs_cast = g.cast_stack.last() != greater_typ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if needs_cast {
|
if needs_cast {
|
||||||
if g.ns.name == 'builtin' {
|
if g.ns.name == 'builtin' {
|
||||||
g.write('new ')
|
g.write('new ')
|
||||||
|
|
|
@ -284,7 +284,9 @@ fn (mut g Gen) println(comment string) {
|
||||||
if s.len == 1 {
|
if s.len == 1 {
|
||||||
print(term.blue('0'))
|
print(term.blue('0'))
|
||||||
}
|
}
|
||||||
print(term.blue(g.buf[i].hex()) + ' ')
|
gbihex := g.buf[i].hex()
|
||||||
|
hexstr := term.blue(gbihex) + ' '
|
||||||
|
print(hexstr)
|
||||||
}
|
}
|
||||||
g.debug_pos = g.buf.len
|
g.debug_pos = g.buf.len
|
||||||
print(' ' + comment)
|
print(' ' + comment)
|
||||||
|
|
|
@ -267,14 +267,16 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
|
||||||
is_public: is_field_pub
|
is_public: is_field_pub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is_pub_field := is_embed || is_field_pub
|
||||||
|
is_mut_field := is_embed || is_field_mut
|
||||||
// save embeds as table fields too, it will be used in generation phase
|
// save embeds as table fields too, it will be used in generation phase
|
||||||
fields << table.Field{
|
fields << table.Field{
|
||||||
name: field_name
|
name: field_name
|
||||||
typ: typ
|
typ: typ
|
||||||
default_expr: ast.ex2fe(default_expr)
|
default_expr: ast.ex2fe(default_expr)
|
||||||
has_default_expr: has_default_expr
|
has_default_expr: has_default_expr
|
||||||
is_pub: if is_embed { true } else { is_field_pub }
|
is_pub: is_pub_field
|
||||||
is_mut: if is_embed { true } else { is_field_mut }
|
is_mut: is_mut_field
|
||||||
is_global: is_field_global
|
is_global: is_field_global
|
||||||
attrs: p.attrs
|
attrs: p.attrs
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
|
||||||
// for i, arg in args {
|
// for i, arg in args {
|
||||||
for i := 0; i < args.len; i++ {
|
for i := 0; i < args.len; i++ {
|
||||||
arg := args[i]
|
arg := args[i]
|
||||||
current_args := args[i..]
|
current_args := args[i..].clone()
|
||||||
match arg {
|
match arg {
|
||||||
'-apk' {
|
'-apk' {
|
||||||
res.is_apk = true
|
res.is_apk = true
|
||||||
|
@ -441,12 +441,12 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
|
||||||
command_pos = i
|
command_pos = i
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if command !in ['', 'build-module'] {
|
if command != '' && command != 'build-module' {
|
||||||
// arguments for e.g. fmt should be checked elsewhere
|
// arguments for e.g. fmt should be checked elsewhere
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
eprint('Unknown argument `$arg`')
|
extension := if command.len == 0 { '' } else { ' for command `$command`' }
|
||||||
eprintln(if command.len == 0 { '' } else { ' for command `$command`' })
|
eprintln('Unknown argument `$arg`$extension')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,10 @@ pub fn cc_from_string(cc_str string) CompilerType {
|
||||||
return .gcc
|
return .gcc
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
cc := cc_str.replace('\\', '/').split('/').last().all_before('.')
|
normalized_cc := cc_str.replace('\\', '/')
|
||||||
|
normalized_cc_array := normalized_cc.split('/')
|
||||||
|
last_elem := normalized_cc_array.last()
|
||||||
|
cc := last_elem.all_before('.')
|
||||||
if '++' in cc {
|
if '++' in cc {
|
||||||
return .cplusplus
|
return .cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue