diff options
author | Himbeer <himbeer@disroot.org> | 2024-09-04 16:03:20 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-09-04 16:03:20 +0200 |
commit | 413e267d0ed01c426002ec6488f05a5d7a619e5a (patch) | |
tree | be54b983ff508f2c81837e2baa6734ae8d37c24b /generate.go | |
parent | f27272532c25180a7f2d4b0f5f1d50c0a1a04564 (diff) |
Require extern functions to be declared
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) |