cgen: optional fixes; make http compile
parent
9e201e1f93
commit
d7ae9d7279
|
@ -28,11 +28,11 @@ mut:
|
|||
pub struct FetchConfig {
|
||||
pub mut:
|
||||
method string
|
||||
data string=''
|
||||
params map[string]string=map[string]string
|
||||
headers map[string]string=map[string]string
|
||||
cookies map[string]string=map[string]string
|
||||
user_agent string='v'
|
||||
data string
|
||||
params map[string]string
|
||||
headers map[string]string
|
||||
cookies map[string]string
|
||||
user_agent string//='v' QTODO
|
||||
verbose bool=false
|
||||
}
|
||||
|
||||
|
|
|
@ -1858,7 +1858,8 @@ fn (g mut Gen) return_statement(node ast.Return) {
|
|||
}
|
||||
ast.CallExpr {
|
||||
// TODO: why?
|
||||
if !it.is_method {
|
||||
// if !it.is_method {
|
||||
if it.name == 'error' {
|
||||
is_error = true // TODO check name 'error'
|
||||
}
|
||||
}
|
||||
|
@ -2564,9 +2565,15 @@ fn (g mut Gen) fn_call(node ast.CallExpr) {
|
|||
// println(var) or println println(str.var)
|
||||
expr := node.args[0].expr
|
||||
is_var := match expr {
|
||||
ast.SelectorExpr { true }
|
||||
ast.Ident { true }
|
||||
else { false }
|
||||
ast.SelectorExpr {
|
||||
true
|
||||
}
|
||||
ast.Ident {
|
||||
true
|
||||
}
|
||||
else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// `println(int_str(10))`
|
||||
// sym := g.table.get_type_symbol(node.args[0].typ)
|
||||
|
@ -3117,7 +3124,6 @@ fn (g mut Gen) gen_str_for_struct(info table.Struct, styp string) {
|
|||
g.gen_str_for_type(sym, field_styp)
|
||||
}
|
||||
}
|
||||
|
||||
s := styp.replace('.', '__')
|
||||
g.definitions.write('string ${s}_str($styp it, int indent_count) {\n')
|
||||
// generate ident / indent length = 4 spaces
|
||||
|
@ -3154,7 +3160,7 @@ fn (g mut Gen) gen_str_for_struct(info table.Struct, styp string) {
|
|||
fn (g Gen) type_to_fmt(typ table.Type) string {
|
||||
sym := g.table.get_type_symbol(typ)
|
||||
if sym.kind == .struct_ {
|
||||
return "%.*s"
|
||||
return '%.*s'
|
||||
} else if typ == table.string_type {
|
||||
return "\'%.*s\'"
|
||||
} else if typ == table.bool_type {
|
||||
|
|
Loading…
Reference in New Issue