From 9a938d3ce26b2d3728d791c0f858acdbd50223b5 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sun, 23 Jan 2022 21:16:02 +0000 Subject: =?UTF-8?q?Rework=20symbol=20lookup=20to=20use=20lexical=20scoping?= =?UTF-8?q?,=20and=20implement=20recursive=20function=20call=20via=20?= =?UTF-8?q?=E2=88=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apl9.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'apl9.h') diff --git a/apl9.h b/apl9.h index 78b5c11..7f194d0 100644 --- a/apl9.h +++ b/apl9.h @@ -67,6 +67,7 @@ typedef struct Symbol Symbol; typedef struct Symtab Symtab; typedef struct QuadnameDef QuadnameDef; typedef struct ErrorHandler ErrorHandler; +typedef struct DfnFrame DfnFrame; struct Array { @@ -178,6 +179,13 @@ struct ErrorHandler jmp_buf jmp; }; +struct DfnFrame +{ + Rune *code; + Symtab *symtab; + DfnFrame *prev; +}; + /* Function prototypes for the different source files */ /* main.c */ Datum *evalline(Rune *, int); @@ -214,9 +222,15 @@ Array *fillelement(Array *); Datum *eval(Statement *, int); /* symbol.c */ -Symbol *getsym(Symtab *, Rune *); -Symtab *newsymtab(void); -void freesymtab(Symtab *); +Symbol *getsym(Rune *); +void initsymtab(void); +DfnFrame *getcurrentdfn(void); +DfnFrame *pushdfnframe(Rune *); +void popdfnframe(void); +vlong globalIO(void); +void globalIOset(vlong); +int globalDIV(void); +void globalDIVset(int); /* memory.c */ void *emalloc(ulong); @@ -271,6 +285,7 @@ Array *fnShape(Array *); Array *fnReverseLast(Array *); Array *fnReverseFirst(Array *); Array *fnTranspose(Array *); +Array *fnSelfRef1(Array *); /* Dyadic functions from function.c */ Array *fnPlus(Array *, Array *); @@ -300,6 +315,7 @@ Array *fnIndex(Array *, Array *); Array *fnCatenateLast(Array *, Array *); Array *fnCatenateFirst(Array *, Array *); Array *fnReshape(Array *, Array *); +Array *fnSelfRef2(Array *, Array *); /* Monadic operators from operators.c */ Array *opEach(Datum *, Array *, Array *); @@ -332,10 +348,8 @@ extern opmonad monadoperatordefs[]; /* operators.c */ extern opdyad dyadoperatordefs[]; /* operators.c */ extern fndyad hybridfunctiondefs[]; /* hybrids.c */ extern opmonad hybridoperatordefs[]; /* hybrids.c */ -extern Symtab *globalsymtab; /* symbol.c */ -extern Symtab *currentsymtab; /* symbol.c */ extern int alloccounts; /* memory.c */ extern QuadnameDef quadnames[]; /* quadnames.c */ extern int printprecision; /* print.c */ extern ErrorHandler globalerror; /* error.c */ -extern Rune *errorstrs[]; /* error.c */ \ No newline at end of file +extern Rune *errorstrs[]; /* error.c */ -- cgit v1.2.3