compiler: add support for panic_debug with -cg
parent
0b750a234f
commit
242670a33d
|
@ -213,6 +213,7 @@ pub:
|
|||
is_builtin bool // this function is defined in builtin/strconv
|
||||
ctdefine string // has [if myflag] tag
|
||||
pos token.Position
|
||||
file string
|
||||
pub mut:
|
||||
return_type table.Type
|
||||
}
|
||||
|
@ -930,7 +931,7 @@ fn (stmt Stmt) position() token.Position {
|
|||
}
|
||||
|
||||
// TODO: remove this fugly hack :-|
|
||||
// fe2ex/1 and ex2fe/1 are used to convert back and forth from
|
||||
// fe2ex/1 and ex2fe/1 are used to convert back and forth from
|
||||
// table.FExpr to ast.Expr , which in turn is needed to break
|
||||
// a dependency cycle between v.ast and v.table, for the single
|
||||
// field table.Field.default_expr, which should be ast.Expr
|
||||
|
|
|
@ -479,6 +479,14 @@ fn (mut g Gen) fn_call(node ast.CallExpr) {
|
|||
}
|
||||
g.write('))')
|
||||
}
|
||||
} else if g.pref.is_debug && node.name == 'panic' {
|
||||
paline := node.pos.line_nr + 1
|
||||
pafile := g.fn_decl.file
|
||||
pafn := g.fn_decl.name.after('.')
|
||||
pamod := g.fn_decl.name.all_before_last('.')
|
||||
g.write('panic_debug($paline, tos3("$pafile"), tos3("$pamod"), tos3("$pafn"), ')
|
||||
g.call_args(node.args, node.expected_arg_types)
|
||||
g.write(')')
|
||||
} else {
|
||||
g.write('${name}(')
|
||||
g.call_args(node.args, node.expected_arg_types)
|
||||
|
|
|
@ -255,6 +255,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
is_js: is_js
|
||||
no_body: no_body
|
||||
pos: start_pos.extend(end_pos)
|
||||
file: p.file_name
|
||||
is_builtin: p.builtin_mod || p.mod in util.builtin_module_parts
|
||||
ctdefine: ctdefine
|
||||
}
|
||||
|
@ -305,6 +306,7 @@ fn (mut p Parser) anon_fn() ast.AnonFn {
|
|||
is_anon: true
|
||||
no_body: no_body
|
||||
pos: pos
|
||||
file: p.file_name
|
||||
}
|
||||
typ: typ
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ pub fn parse_file(path string, b_table &table.Table, comments_mode scanner.Comme
|
|||
if p.pref.is_script && !p.pref.is_test && p.mod == 'main' && !have_fn_main(stmts) {
|
||||
stmts << ast.FnDecl {
|
||||
name: 'main'
|
||||
file: p.file_name
|
||||
return_type: table.void_type
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,6 +286,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
|||
mut method := ast.FnDecl{
|
||||
name: name
|
||||
args: args
|
||||
file: p.file_name
|
||||
return_type: table.void_type
|
||||
}
|
||||
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
|
||||
|
|
Loading…
Reference in New Issue