" This file contains the first pass of the MUDDLE compiler. The functions therein take a MUDDLE function and build a more detailed model of it. Each entity in the function is represented by an object of type NODE. The entire function is represented by the functions node and it points to the rest of the nodes for the function." " Nodes vary in complexity and size depending on what they represent. A function or prog/repeat node is contains more information than a node for a quoted object. All nodes have some fields in common to allow general programs to traverse the model." " The model built by PASS1 is used by the analyzer (SYMANA), the variable allocator (VARANA) and the code generator (CODGEN). In some cases the analyzers and generators for certain classes of SUBRs are together in their own files (e.g. CARITH, STRUCT, ISTRUC)." " This the top level program for PASS1. It takes a function as input and returns the data structure representing the model." ) (JUSTDCL <>) (RNAME .NAME) "AUX" RESULT (VARTBL ,LVARTBL) (DCL #DECL ()) (ARGL ()) (HATOM <>) (TT ()) (FCN .FUNC) TEM (RQRG 0) (TRG 0) INAME) #DECL ((FUNC) FUNCTION (VARTBL) (RQRG TRG) (FCN) (ARGL TT) LIST (RESULT) (INAME) ) > ATOM> > >> > > > > DECL>> > >)> > > >) (ELSE > '>>> .INAME () <1 .TT> <2 .TT> .HATOM .VARTBL 3> <3 .TT>)> .TRG .RQRG>> > !)>)> > .FCN>>> .RESULT> " This function (and others on this page) take an arg list and decls and parses them producing 3 things. 1) An RSUBR decl list. 2) A machine readable binding specification. 3) Possibly an AC call spec. Atoms are also entered into the symbol table." ) "AUX" (SVTBL .VARTBL) (ACS:BOT ) (NACS 1) (RES:TOP (())) (RES:BOT .RES:TOP) (ARGN 1) (BNDL:TOP (())) (BNDL:BOT .BNDL:TOP) (MODE ,TOT-MODES) (DOIT ,INIT-D) (ST <>) T T1 SVT (IX 0) TIX VIX) #DECL ((ACS:BOT RES:BOT BNDL:TOP BNDL:BOT) (RES:TOP) LIST (ACS:TOP) > (NACS ARGN) (VIX) (MODE) > (IX) FIX (DOIT) (ARGL) LIST (SVTBL SVT) SYMTAB (DCL) >) > > ATOM FORM LIST>> > ) ( > > > >>>> > >) (ELSE "OPT"> "OPTIONAL") (ELSE <1 .ARGL>)>)>)>) (ELSE )> >> >> ) ) (> )> > <==? 2> SPECIAL> <==? <1 .DC1> UNSPECIAL>>> >)> <>>>> LIST>> >> .SVTBL> ) (ELSE >)>>)> > 0> > <=? .ACS:TOP '(() STACK)>> (N1 N2) FIX (TEM) SYMTAB) > > > )> >>>>> > ) (ELSE )>) (ELSE )> > >>)> ( !)) (ELSE ())!>)> ) >> > > >>> "Vector of legal strings in decl list." "Amount to rest off decl vector after each encounter." "This function used for normal args when \"BIND\" and \"CALL\" still possible." ) > > "This function for normal args when \"CALL\" still possible." ) > > "Handle a normal argument or quoted normal argument." > > T>)>) (> T>)>)> >> "Handle \"BIND\" decl." > > T>> > "Handle \"CALL\" decl." > > T>>)> > > "Flush on extra atoms after \"CALL\", \"ARGS\" etc." > "Handle \"OPTIONAL\" decl." )> ;"Temporary until know how to win." <>>)>) (<==? .TYP FORM> > <>>)>) (> ATOM> > 7>)>) ( > > 6>)>) (ELSE )> >> "Handle \"ARGS\" decl." ) )> ;"Temporary until know how to win." > <>>>)> >> "Handle \"TUPLE\" decl." > ) (ELSE >)> <>>>)> > "Handle \"AUX\" decl." > <>>) (> ATOM> 2>) (ELSE )>> "Handle \"NAME\" and \"ACT\" decl." > <>>> > "Fixup activation atoms after node generated." )) #DECL ((N) NODE (L) ) > >> 1> >> )> >>> "Table of varius decl handlers." (RESTS) > "Check for quoted arguments." 2> <==? <1 .OB> QUOTE> ATOM>> <2 .OB>) (ELSE T)>> "Chech for (arg init) or ('arg init)." 2> ATOM> FORM> >>>> <1 .OB>) (ELSE T)>> "Add a decl to RSUBR decls and update AC call spec." >> <=? .ACS:TOP '(() STACK)>>> )> >) (> STRING> >) (ELSE )>>> > ))>>> >) (> 7> > >))>>>) (ELSE )>)> T>> "Add code to set up a certain kind of argument." <==? 2> SPECIAL>> <==? <1 .DC1> UNSPECIAL>>> >) (ELSE )> .VAL>> >> ;"Can specials commute?" > >>) (ELSE >>)> .DC> "Find decl associated with a variable, if none, use ANY." (ATM) ATOM) >>> > LIST>> )> LIST>> >> >>> "Add an AUX variable spec to structure." > TUPLE> <==? <1 .OBJ> ITUPLE>>> TUPLE> ,COPY-CODE) (ELSE ,ISTRUC-CODE)> () TUPLE <1 .OBJ> () ,<1 .OBJ>>> ,ISTRUC-CODE> 3> <3 .OBJ>) (ELSE #LOSE *000000000000*)> .TT>> ,QUOTE-CODE> .TT>> ;"Reanalyze it." )> .TT> .EV)>) (ELSE > >>)>) (ELSE >)> >> "Main dispatch function during pass1." (VALUE) NODE) PTHIS-TYPE> ,PDEFAULT> .OBJ>> "Build a node for <> or #FALSE ()." ()>> PTHIS-OBJECT ,FALSE-QT> "Build a node for ()." > "Build a node for a LIST, VECTOR or UVECTOR." () <>>)) #DECL ((VALUE) NODE (TT) NODE) > .OBJ>>> "Build a node for unknown things." .OBJ ()>> "Further analyze a FORM and build appropriate node." (VALUE) NODE) )) #DECL ((APPLICATION) (APPLY) ) PAPPLY-TYPE> ,PAPDEF> .OBJ .APPLY>>> "Build a SEGMENT node." <> ()>)) #DECL ((TT VALUE PARENT) NODE) >)>> "Analyze a form or the form " ) ( ) (.REASONABLE ) (ELSE )>> "Expand MACRO and process result." > ;"Turn On new Error" ) >> ;"Turn OFF new Error" ) (ELSE )>> ) (>> > ) (> )>> > ,MACACT>) (ELSE )>> "Build a node for a form whose 1st element is a form (could be NTH)." 2> >> .OBJ () .AP>> > .OBJ>>) (ELSE )>> "Build a node for strange forms." .OBJ () .AP>> "For objects that require EVAL, make sure all atoms used are special." ) > > 2> <==? <1 .OB> LVAL> > ATOM>> <==? <1 .OB> SET> > ATOM>>> >> > )>)> '![FORM LIST UVECTOR VECTOR!]> ,SPECIALIZE .OBJ>)>> "Build a SUBR call node." > () .AP>)) #DECL ((TT) NODE (VALUE) NODE (OBJ) FORM) > >>> ) ( <2 .THING>) (ELSE .DEFAULT)>> )) #DECL ((TT VALUE) NODE (OBJ) FORM) <==? .LN 3> > INTH)(ELSE IPUT)> () ,NTH) (ELSE ,PUT)>>> .TT> ! ()) (ELSE ( .TT>))>)>> "PROG/REPEAT node." ) TT (DCL #DECL ()) (HATOM <>) ARGL (VARTBL .VARTBL)) #DECL ((OBJ) (TT) NODE (VALUE) NODE (DCL) DECL (ARGL) LIST (VARTBL) ) >> > ATOM> > >> > > > DECL> > >> > .NAME () .AP <2 > STRING>> .ARGL) (ELSE ("AUX" !.ARGL))> .DCL .HATOM>> .HATOM .VARTBL>> > > .OBJ>> .TT> "Unwind compiler." <1 .OBJ> () .AP>)) #DECL ((PARENT VALUE TT) NODE (OBJ) FORM) 3> .TT> .TT>)>) (ELSE )>> "Build a node for a COND." COND ()>)) #DECL ((PARENT) (OBJ)
(VALUE) NODE) <> ()>)) #DECL ((TT) NODE) >> .TT>> > >>) (ELSE )>> >>> > > > "Build a node for '<-object>-." () ()>)) #DECL ((TT VALUE) NODE (OBJ) FORM) >> >> >)>> "Build a node for a call to an RSUBR." <1 .OBJ> () .AP>)) #DECL ((OBJ) FORM (AP) (PARENT) (VALUE) NODE) 2> DECL>> .OBJ <3 .AP>>> > >>) (ELSE )>> > <1 .OBJ> () .AP>)) #DECL ((OBJ) FORM (AP) IRSUBR (PARENT) ) .OBJ <1 .AP>>> > >>> "Predicate: any segments in this object?" ) >> SEGMENT> > >>> "Analyze a call to an RSUBR with decls checking number of args and types wherever possible." ) (SGD '<>) (SGP '(1)) SGN (IX 0) DC (RM ,RMODES) (ARG-NUMBER 0) (KDS (())) (TKDS .KDS) RMT (OB ) (ST <>)) #DECL ((TKDS KDS) (OB) LIST (OBJ) > (RM) > (ARG-NUMBER) FIX (RDCL) > (DOIT SEGSW) (IX) FIX (NAME) (SGD) FORM (SGP) (SGN) NODE) ) > > > >)> )> > > >>> .ST>> ;"TUPLE seen." ALL>>)>) ( 4> >> ) (.SEGSW > .SGD>> >) (ELSE >>)>) ( SEGMENT> >>)>>> > <1 .OB>>> >) (ELSE )>) (ELSE > ,SEGMENT-CODE> >> > >) (ELSE .DC> > >)>)> .TT> >> >)> > LIST>>> > ) ()>>> > > >)>)>) ( >) (.SEGSW .SGD>) (ELSE .SGD)>> >) (ELSE )>>> "Flush one possible decl away." ) > > T> "Handle Normal arg when \"VALUE\" still possible." ) > > "Handle Normal arg when \"CALL\" still possible." ) > > "Handle normal arg." .PARENT>>> .DC> > > .TT> "Handle \"QUOTE\" arg." > <1 .OB> ()>>> .DC> > .TT> "Handle \"CALL\" decl." >> .DC> > .RSB>> "Handle \"ARGS\" decl." >> .DC> > .RSB>> "Handle \"TUPLE\" decl." .PARENT>>> .DC> > > .TT> "Handle stuff with segments in arguments." >> STRUCTURED> > .TT> > >> "Handle \"VALUE\" chop decl and do the rest." (PARENT) NODE) > STRING>> > .F> > (RDOIT SDOIT) UVECTOR> "Create a node for a call to a function." (VALUE) NODE) ATOM> .FCNS> >>> <1 .OB> .OB>) ( RSUB-DEC>> .OB>) (.REASONABLE ) (ELSE > >)>) ( FUNCTION> > > )>> "Call compiler recursively to compile anonymous function." ) T GROUP-NAME) #DECL ((INT? GROUP-NAME) > (VALUE) NODE) ; "Use APPLY to avoid compilation probs." > "#FUNCTION (....) compiler -- call ANONF." )) > " compiler -- call ANONF." )) #DECL ((OB) ) FUNCTION>>> "Handle RSUBR that is really a function." .NAME () .BODY>)) #DECL ((PARENT) (VALUE) NODE) >>>> > >>> "Handle an RSUBR that is already an RSUBR." .NAME () .BODY>)) #DECL ((BODY) (PARENT) (VALUE) NODE) >> > >>> .NAME () FOO>)) #DECL ((PARENT) (VALUE) NODE) > > >>> ;"ILIST, ISTRING, IVECTOR AND IUVECTOR" > > > > > > ) (LN ) N EV SIZ) #DECL ((VALUE N EV TT) NODE (LN) FIX (OBJ) ) ) (ELSE ) ( )>) (<1? .LN>) ()> .TT>> > >)> .TT>> <3 .OBJ>) (<==? .TYP STRING> ) (<==? .TYP BYTES> 0) (ELSE #LOSE 0)> .TT>> ,QUOTE-CODE> .TT>> ;"Reanalyze it." )> ) (ELSE )>)>> "READ, READCHR, READSTRING, NEXTCHR, READB, GET, GETL, GETPROP, GETPL" >> >> >> >> >> >> ) N (TEM 0)) #DECL ((VALUE) NODE (TT) NODE (N) (LN) FIX (TEM ARGN) FIX (OBJ) ) .ARGN>> ) (ELSE > )) #DECL ((EV) NODE) > .ARGN> ,QUOTE-CODE> .TT>> )> <> (.EV)>>)> .EV> >> )>> >> >> >> >> ) TT) #DECL ((OBJ) FORM (LN) FIX (TT VALUE TEM T2 EV) NODE) > > ) (ELSE > .TT>> .TT>> ) (ELSE .TT>> ,QUOTE-CODE> .TT>> )> )> .TT)>> FIX>) > >)> ) ( )> T>