mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: remove no longer needed special case & fix tmpl
This commit is contained in:
parent
6349bd33d3
commit
3107618732
@ -169,9 +169,7 @@ fn (p mut Parser) comp_time() {
|
||||
}
|
||||
p.import_table.register_used_import('strings')
|
||||
p.genln('/////////////////// tmpl start')
|
||||
p.is_vweb = true
|
||||
p.statements_from_text(v_code, false)
|
||||
p.is_vweb = false
|
||||
p.genln('/////////////////// tmpl end')
|
||||
receiver := p.cur_fn.args[0]
|
||||
dot := if receiver.is_mut || receiver.ptr { '->' } else { '.' }
|
||||
|
@ -402,9 +402,7 @@ fn (p mut Parser) fn_decl() {
|
||||
}
|
||||
}
|
||||
dll_export_linkage := p.get_linkage_prefix()
|
||||
if !p.is_vweb {
|
||||
p.set_current_fn( f )
|
||||
}
|
||||
p.set_current_fn( f )
|
||||
// Generate `User_register()` instead of `register()`
|
||||
// Internally it's still stored as "register" in type User
|
||||
mut fn_name_cgen := p.table.fn_gen_name(f)
|
||||
@ -517,10 +515,8 @@ fn (p mut Parser) fn_decl() {
|
||||
p.genln(p.print_prof_counters())
|
||||
}
|
||||
// Counting or not, always need to add defer before the end
|
||||
if !p.is_vweb {
|
||||
if f.defer_text.len > f.scope_level {
|
||||
if f.defer_text.len > f.scope_level {
|
||||
p.genln(f.defer_text[f.scope_level])
|
||||
}
|
||||
}
|
||||
if typ != 'void' && !p.returns {
|
||||
p.error_with_token_index('$f.name must return "$typ"', f.fn_name_token_idx)
|
||||
|
@ -68,7 +68,6 @@ mut:
|
||||
is_const_literal bool // `1`, `2.0` etc, so that `u64_var == 0` works
|
||||
in_dispatch bool // dispatching generic instance?
|
||||
is_vgen bool
|
||||
is_vweb bool
|
||||
is_sql bool
|
||||
is_js bool
|
||||
sql_i int // $1 $2 $3
|
||||
@ -1172,7 +1171,7 @@ fn (p mut Parser) gen(s string) {
|
||||
// Generate V header from V source
|
||||
fn (p mut Parser) statement(add_semi bool) string {
|
||||
p.expected_type = ''
|
||||
if p.returns && !p.is_vweb {
|
||||
if p.returns {
|
||||
p.error('unreachable code')
|
||||
}
|
||||
// if !p.in_dispatch {
|
||||
@ -2833,7 +2832,7 @@ fn (p mut Parser) return_st() {
|
||||
}
|
||||
else {
|
||||
// Don't allow `return val` in functions that don't return anything
|
||||
if !p.is_vweb && (p.tok == .name || p.tok == .number || p.tok == .str) {
|
||||
if p.tok == .name || p.tok == .number || p.tok == .str {
|
||||
p.error_with_token_index('function `$p.cur_fn.name` should not return a value', p.cur_fn.fn_name_token_idx)
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,7 @@ _ = header
|
||||
}
|
||||
}
|
||||
s.writeln(STR_END)
|
||||
s.writeln('tmpl_res := sb.str() ')
|
||||
s.writeln('return tmpl_res }')
|
||||
s.writeln('tmpl_res := sb.str() }')
|
||||
return s.str()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user