mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix high order fns
This commit is contained in:
parent
9c586e7e92
commit
54b069f9ad
@ -759,7 +759,12 @@ fn (p mut Parser) get_type() string {
|
|||||||
if debug {
|
if debug {
|
||||||
println('same line getting type')
|
println('same line getting type')
|
||||||
}
|
}
|
||||||
f.typ = p.get_type()
|
if p.tok == .name {
|
||||||
|
f.typ = p.get_type()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
f.typ = 'void'
|
||||||
|
}
|
||||||
// println('fn return typ=$f.typ')
|
// println('fn return typ=$f.typ')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1380,7 +1385,7 @@ fn (p mut Parser) name_expr() string {
|
|||||||
enum_type := p.table.find_type(name)
|
enum_type := p.table.find_type(name)
|
||||||
if !enum_type.is_enum {
|
if !enum_type.is_enum {
|
||||||
p.error('`$name` is not an enum')
|
p.error('`$name` is not an enum')
|
||||||
}
|
}
|
||||||
p.next()
|
p.next()
|
||||||
p.check(.dot)
|
p.check(.dot)
|
||||||
val := p.lit
|
val := p.lit
|
||||||
@ -1441,7 +1446,6 @@ fn (p mut Parser) name_expr() string {
|
|||||||
if f.name == '' {
|
if f.name == '' {
|
||||||
// We are in a second pass, that means this function was not defined, throw an error.
|
// We are in a second pass, that means this function was not defined, throw an error.
|
||||||
if !p.first_run() {
|
if !p.first_run() {
|
||||||
// println('name_expr():')
|
|
||||||
// If orig_name is a pkg, then printing undefined: `pkg` tells us nothing
|
// If orig_name is a pkg, then printing undefined: `pkg` tells us nothing
|
||||||
// if p.table.known_pkg(orig_name) {
|
// if p.table.known_pkg(orig_name) {
|
||||||
if p.table.known_pkg(orig_name) || p.import_table.known_alias(orig_name) {
|
if p.table.known_pkg(orig_name) || p.import_table.known_alias(orig_name) {
|
||||||
@ -1453,6 +1457,7 @@ fn (p mut Parser) name_expr() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.next()
|
p.next()
|
||||||
|
// First pass, the function can be defined later.
|
||||||
return 'void'
|
return 'void'
|
||||||
}
|
}
|
||||||
// no () after func, so func is an argument, just gen its name
|
// no () after func, so func is an argument, just gen its name
|
||||||
@ -1484,14 +1489,13 @@ fn (p mut Parser) name_expr() string {
|
|||||||
fn (p mut Parser) var_expr(v Var) string {
|
fn (p mut Parser) var_expr(v Var) string {
|
||||||
p.log('\nvar_expr() v.name="$v.name" v.typ="$v.typ"')
|
p.log('\nvar_expr() v.name="$v.name" v.typ="$v.typ"')
|
||||||
// println('var expr is_tmp=$p.cgen.is_tmp\n')
|
// println('var expr is_tmp=$p.cgen.is_tmp\n')
|
||||||
// p.gen('VAR EXPR ')
|
|
||||||
p.cur_fn.mark_var_used(v)
|
p.cur_fn.mark_var_used(v)
|
||||||
fn_ph := p.cgen.add_placeholder()
|
fn_ph := p.cgen.add_placeholder()
|
||||||
p.expr_var = v
|
p.expr_var = v
|
||||||
p.gen(p.table.var_cgen_name(v.name))
|
p.gen(p.table.var_cgen_name(v.name))
|
||||||
p.next()
|
p.next()
|
||||||
mut typ := v.typ
|
mut typ := v.typ
|
||||||
// fn_pointer()
|
// Function pointer?
|
||||||
if typ.starts_with('fn ') {
|
if typ.starts_with('fn ') {
|
||||||
println('CALLING FN PTR')
|
println('CALLING FN PTR')
|
||||||
p.print_tok()
|
p.print_tok()
|
||||||
|
Loading…
Reference in New Issue
Block a user