fix single file programs without fn main and REPL (allow imports,

function definitions, consts, etc)
This commit is contained in:
Alexander Medvednikov 2019-06-28 12:41:09 +02:00
parent fd9163f715
commit bd49977feb
5 changed files with 31 additions and 28 deletions

View file

@ -210,7 +210,7 @@ fn (table &Table) known_type(typ string) bool {
return false
}
// TODO PERF O(N) this slows down the comiler a lot!
// TODO PERF O(N) this slows down the compiler a lot!
fn (t &Table) find_fn(name string) Fn {
for f in t.fns {
if f.name == name {
@ -220,7 +220,7 @@ fn (t &Table) find_fn(name string) Fn {
return Fn{}
}
// TODO PERF O(N) this slows down the comiler a lot!
// TODO PERF O(N) this slows down the compiler a lot!
fn (t &Table) known_fn(name string) bool {
for f in t.fns {
if f.name == name {
@ -249,10 +249,9 @@ fn (t mut Table) register_type(typ string) {
// if t.types.filter( _.name == typ.name).len > 0 {
// return
// }
datyp := Type {
t.types << Type {
name: typ
}
t.types << datyp
}
fn (p mut Parser) register_type_with_parent(strtyp, parent string) {