diff options
Diffstat (limited to 'generate.go')
-rw-r--r-- | generate.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/generate.go b/generate.go index b8c6ba2..a5ddf7f 100644 --- a/generate.go +++ b/generate.go @@ -90,6 +90,11 @@ func generateFunction(function *functionExpr, w io.Writer) error { defer func() { currentFunc = "" }() funcs[currentFunc] = struct{}{} + + if function.external { + return nil + } + localConsts[currentFunc] = map[string]string{} localMuts[currentFunc] = map[string]struct{}{} @@ -579,6 +584,15 @@ func (n *numberExpr) generate(w io.Writer) (string, error) { } func (c *callExpr) generate(w io.Writer) (string, error) { + _, ok := funcs[c.funcName] + if !ok { + return "", errUndeclared{ + name: c.funcName, + isFunc: true, + line: c.line(), + } + } + ret := allocReg() fmt.Fprintf(w, "%s =w call $%s(", ret, c.funcName) |