compiler: cache modules

This commit is contained in:
Alexander Medvednikov 2019-10-04 15:48:09 +03:00 committed by GitHub
parent f45d3f07ed
commit 52f4f4026b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 422 additions and 242 deletions

View file

@ -144,6 +144,7 @@ fn (p mut Parser) is_sig() bool {
fn (p mut Parser) fn_decl() {
p.clear_vars() // clear local vars every time a new fn is started
p.fgen('fn ')
//defer { p.fgenln('\n') }
// If we are in the first pass, create a new function.
// In the second pass fetch the one we created.
@ -426,10 +427,17 @@ fn (p mut Parser) fn_decl() {
if !is_c && p.first_pass() {
// TODO hack to make Volt compile without -embed_vlib
if f.name == 'darwin__nsstring' && p.pref.build_mode == .default_mode {
return
} else {
p.cgen.fns << fn_decl + ';'
}
p.cgen.fns << fn_decl + ';'
}
// Generate .vh header files when building a module
/*
if p.pref.build_mode == .build_module {
p.vh_genln(f.v_definition())
}
*/
return
}
if p.attr == 'live' && p.pref.is_so {
@ -1092,11 +1100,6 @@ fn (f &Fn) typ_str() string {
return sb.str()
}
// "fn foo(a int) stirng", for .vh module headers
fn (f &Fn) v_definition() string {
return 'fn '//$f.name(${f.str_args()})'
}
// f.args => "int a, string b"
fn (f &Fn) str_args(table &Table) string {
mut s := ''