📄 itcl.puma
字号:
one_word (next := next, env := e, ident := ident, pos := pos) :- e->env.objects := object (s, ident, e->env.objects); dcl (e->env.objects, PAF_PUBLIC); get_param_objects (next); .word_c (next := next) :- get_param_objects (next); /* ignore garbage */ ./**************************************************************/PROCEDURE add_variables (tIdent, word_c, attr: int)(iset), w2: word_c (next := noword (...)), _ :- /* set r */ add_var (w2, PAF_REF_READ, default_attr); .(iset), w2, _ :- /* set w x */ add_var (w2, PAF_REF_WRITE, default_attr); .(iglobal), w2, _ :- /* global d ... */ add_global_vars (w2); .(ivariable), w2: word_c (next := noword (...)), _ :- /* variable d */ add_variable_vars (w2, PAF_REF_READ, attr); .(ivariable), w2: word_c (next := /* variable w x {} */ w3: word_c (next := w4: qual_word (env := env, qualification := qualification))), _ :- relocate (qualification, menv (mnoobject (), env, w4)); add_variable_vars (w2, PAF_REF_WRITE, attr); .(ivariable), w2, _ :- /* variable w x */ add_variable_vars (w2, PAF_REF_WRITE, attr); .(icommon), w2: word_c (next := noword (...)), _ :- /* common d */ add_var (w2, PAF_REF_READ, default_attr); .(icommon), w2, _ :- /* common w x */ add_var (w2, PAF_REF_WRITE, default_attr); .(ipublic), w2: one_word (ident := ident, next := /* public */ w3: word_c (...)), _ :- ident == ivariable || ident == icommon; add_variables (ident, w3, PAF_PUBLIC); .(ipublic), w2: word_c (next := noword (...)), _ :- /* public d */ add_var (w2, PAF_REF_READ, PAF_PUBLIC); .(ipublic), w2: word_c (next := /* public w x {} */ w3: word_c (next := w4: qual_word (env := env, qualification := qualification))), _ :- relocate (qualification, menv (mnoobject (), env, w4)); add_var (w2, PAF_REF_WRITE, PAF_PUBLIC); .(ipublic), w2, _ :- /* public w x */ add_var (w2, PAF_REF_WRITE, PAF_PUBLIC); .(iprotected), w2: one_word (ident := ident, next := /* protected */ w3: word_c (...)), _ :- ident == ivariable || ident == icommon; add_variables (ident, w3, PAF_PROTECTED); .(iprotected), w2: word_c (next := noword (...)), _ :- /* protected d */ add_var (w2, PAF_REF_READ, PAF_PROTECTED); .(iprotected), w2: word_c (next := /* protected w x {} */ w3: word_c (next := w4: qual_word (env := env, qualification := qualification))), _ :- relocate (qualification, menv (mnoobject (), env, w4)); add_var (w2, PAF_REF_WRITE, PAF_PROTECTED); .(iprotected), w2, _ :- /* protected w x */ add_var (w2, PAF_REF_WRITE, PAF_PROTECTED); .(iprivate), w2: one_word (ident := ident, next := /* private */ w3: word_c (...)), _ :- ident == ivariable || ident == icommon; add_variables (ident, w3, PAF_PRIVATE); .(iprivate), w2: word_c (next := noword (...)), _ :- /* private d */ add_var (w2, PAF_REF_READ, PAF_PRIVATE); .(iprivate), w2: word_c (next := /* private w x {} */ w3: word_c (next := w4: qual_word (env := env, qualification := qualification))), _ :- relocate (qualification, menv (mnoobject (), env, w4)); add_var (w2, PAF_REF_WRITE, PAF_PRIVATE); .(iprivate), w2, _ :- /* private w x */ add_var (w2, PAF_REF_WRITE, PAF_PRIVATE); ./*(ilocal), w2: word_c (next := w3: word_c (...)), _ :- /* local c d /* add_var (w3, PAF_REF_READ, default_attr); .(iinherit), w2, _ :- /* inherit x ... /* inherit_var (w2); .*/(iinherit), w2, _ :- /* inherit x ... */ need_pass_2 := rtrue; .(iappend), w2, _ :- /* append w */ add_var (w2, PAF_REF_WRITE, default_attr); .(ilappend), w2, _ :- /* lappend w */ add_var (w2, PAF_REF_WRITE, default_attr); .(iarray), w2: one_word (ident := (iset), next := /* array set w */ w3: word_c (...)), _ :- add_var (w3, PAF_REF_WRITE, default_attr); .(iarray), w2: word_c (next := w3: word_c (...)), _ :- /* array x r */ add_var (w3, PAF_REF_READ, default_attr); .(ibinary), w2: one_word (ident := (iscan), next := /* binary scan x x w ... */ w3: word_c (next := w4: word_c (next := w5: word_c (...)))), _ :- add_vars (w5, PAF_REF_WRITE); .(iscan), w2: word_c (next := /* scan x x w ... */ w3: word_c (next := w4: word_c (...))), _ :- add_vars (w4, PAF_REF_WRITE); .(iforeach), w2, _ :- /* foreach */ add_foreach_vars (w2); .(ivwait), w2, _ :- /* vwait r */ add_var (w2, PAF_REF_READ, default_attr); .(iincr), w2, _ :- /* incr w */ add_var (w2, PAF_REF_WRITE, default_attr); .(iparray), w2, _ :- /* parray r */ add_var (w2, PAF_REF_READ, default_attr); .(icatch), w2: word_c (next := w3: word_c (...)), _ :- /* catch x w */ add_var (w3, PAF_REF_WRITE, default_attr); .(igets), w2: word_c (next := w3: word_c (...)), _ :- /* gets x w */ add_var (w3, PAF_REF_WRITE, default_attr); .(iinfo), w2: one_word (ident := (iexists), next := /* info exists r */ w3: word_c (...)), _ :- add_var (w3, PAF_REF_READ, default_attr); .(iinfo), w2: one_word (ident := (iargs), next := /* info args r */ w3: word_c (...)), _ :- add_var (w3, PAF_REF_READ, default_attr); .(iinfo), w2: one_word (ident := (ibody), next := /* info body r */ w3: word_c (...)), _ :- add_var (w3, PAF_REF_READ, default_attr); .(iinfo), w2: one_word (ident := (idefault), next := /* info default r x w */ w3: word_c (next := w4: word_c (next := w5: word_c (...)))), _ :- add_var (w3, PAF_REF_READ, default_attr); add_var (w5, PAF_REF_WRITE, default_attr); .(itkinfo), w2: one_word (ident := (ivariable), next := /* tkinfo variable r */ w3: word_c (...)), _ :- add_var (w3, PAF_REF_READ, default_attr); .(ifile), w2: one_word (ident := (ilstat), next := /* file lstat x w */ w3: word_c (next := w4: word_c (...))), _ :- add_var (w4, PAF_REF_WRITE, default_attr); .(ifile), w2: one_word (ident := (istat), next := /* file stat x w */ w3: word_c (next := w4: word_c (...))), _ :- add_var (w4, PAF_REF_WRITE, default_attr); .(iunset), w2, _ :- /* unset w ... */ add_vars (w2, PAF_REF_WRITE); ./*(irename), w2, _ :- /* rename r x /* add_var (w2, PAF_REF_READ, default_attr); .(idelete), w2: word_c (next := w3), _ :- /* delete x w ... /* add_vars (w3, PAF_REF_WRITE); .*/(isource), w2: word_c (next := noword (...)), _ :- /* source filename */ include (w2); ./**************************************************************/PROCEDURE include (word_c)one_word (env := env, ident := ident, pos := pos) :- put_symbol (PAF_INCLUDE_DEF, NIL, GetCStr (ident), current_file, (int) pos.Line, (int) pos.Column - 1, (int) pos.Line, (int) (pos.Column + StLength (GetStringRef (ident)) - 1), 0, NIL, NIL, NIL, NIL, 0, 0, 0, 0); .qual_word (env := env, qualification := qualification) :- .qual_words (env := env, qualifications := qualifications) :- ./**************************************************************/PROCEDURE add_global_vars (w: words)/*one_word (ident := ident, env := e, pos := pos, next := next) :- obj: objects; obj := Identify (ident, e); obj != NIL; use (obj, pos, PAF_REF_READ); e->env.objects := object (obj->object.object, ident, e->env.objects); add_global_vars (next); .*/one_word (ident := ident, env := e, pos := pos, next := next) :- genv->env.objects := object (w, ident, genv->env.objects); e->env.objects := object (w, ident, e->env.objects); e := genv; dcl (genv->env.objects, PAF_PUBLIC); add_global_vars (next); ./*qual_word (env := e, qualification := global_ident (pos := pos, ident := ident), next := next) :- obj: objects; obj := IdentifyGlobal (ident); obj != NIL; use (obj, pos, PAF_REF_READ); e->env.objects := object (obj->object.object, ident, e->env.objects); add_global_vars (next); .*/qual_word (qualification := g: global_ident (env := e, pos := pos, ident := ident), next := next) :- genv->env.objects := object (g, ident, genv->env.objects); e->env.objects := object (g, ident, e->env.objects); e := genv; dcl (e->env.objects, PAF_PUBLIC); add_global_vars (next); .qual_word (next := next) ;qual_words (next := next) :- add_global_vars (next); /* crazy: ignore it */ ./**************************************************************/PROCEDURE add_variable_vars (w: [words, qualification_c], acc: int, attr: int)LOCAL { tTree obj, e2; }one_word (ident := ident, env := e: env (object := object), pos := pos, next := next), ... :- ! Tree_IsType (object, kproc_c); e->env.objects := object (w, ident, e->env.objects); dcl (e->env.objects, attr);{ if (acc == PAF_REF_WRITE) use (e->env.objects, pos, acc); }; .one_word (ident := ident, env := e, pos := pos, next := next), ... :- e2 := get_namespace (e); obj := IdentifyLocal (ident, e2->env.objects); obj != NIL; e->env.objects := object (obj->object.object, ident, e->env.objects); use (e->env.objects, pos, acc); .one_word (ident := ident, env := e, pos := pos, next := next), ... :- e2->env.objects := object (w, ident, e2->env.objects); e->env.objects := object (w, ident, e->env.objects); e := e2; dcl (e2->env.objects, attr);{ if (acc == PAF_REF_WRITE) use (e2->env.objects, pos, acc); }; .qual_word (next := next, qualification := qualification), ... :- add_variable_vars (qualification, acc, attr); .qual_words (next := next), ... :- .global_ident (pos := pos, env := e, ident := ident), ... :- obj := IdentifyGlobal (ident); obj != NIL; e->env.objects := object (obj->object.object, ident, e->env.objects); use (e->env.objects, pos, acc); .global_ident (pos := pos, env := e, ident := ident), ... :- genv->env.objects := object (w, ident, genv->env.objects); e->env.objects := object (w, ident, e->env.objects); e := genv; dcl (genv->env.objects, attr);{ if (acc == PAF_REF_WRITE) use (genv->env.objects, pos, acc); }; .q: qualification (pos := pos), ... ;q: complex_qual (pos := pos), ... :- /* pass 2 */ need_pass_2 := rtrue; ./**************************************************************/PROCEDURE add_vars (words, acc: int)w: word_c (next := next), _ :- add_var (w, acc, default_attr); add_vars (next, acc); ./**************************************************************/PROCEDURE add_foreach_vars ([words, stmts])qual_word (qualification := local_text (texts := block (stmts := stmts)), next := word_c (next := next)) :- /* foreach { w ... } */ add_foreach_vars (stmts); add_foreach_vars (next); .w: word_c (next := word_c (next := next)) :- /* foreach w */ add_var (w, PAF_REF_WRITE, default_attr); add_foreach_vars (next); .stmt (next := next, words := words) :- add_vars (words, PAF_REF_WRITE); add_foreach_vars (next); ./**************************************************************/PROCEDURE add_var (w: word_c, acc: int, attr: int)one_word (env := env, ident := ident, pos := pos), ... :- add_var_2 (ident, pos, w, env, acc, attr); .qual_word (env := env, qualification := subscription (qualification := l: local_ident (pos := pos, ident := ident))), ... :- add_var_2 (ident, pos, l, env, acc, attr); .obj_word (env := env, ident := ident, pos := pos), ... :- add_var_2 (ident, pos, w, env, acc, attr); .qual_word (qualification := qualification (pos := pos)), ... ;qual_word (qualification := complex_qual (pos := pos)), ... ;qual_word (qualification := global_ident (pos := pos)), ... ;qual_word (qualification := subscription (pos := pos)), ... :- /* pass 2 */ need_pass_2 := rtrue; ./**************************************************************/PROCEDURE add_var_2 (i: tIdent, pos: tPosition, w: [word_c, qualification_c], e: envs, acc: int, attr:int)... :- obj: objects; obj := IdentifyVariable (i, e); obj != NIL; use (obj, pos, acc); .... :- e->env.objects := object (w, i, e->env.objects); dcl (e->env.objects, attr);{ if (acc == PAF_REF_WRITE) use (e->env.objects, pos, acc); }; ./**************************************************************/FUNCTION IdentifyLocal (i: tIdent, o: objects) objects_, object (object := object, ident := ident, next := next) :- ident == i && ! Tree_IsType (object, kproc_c); RETURN o; ._, object (object := object, ident := ident, next := next) :- RETURN IdentifyLocal (i, next); ._, _ :- RETURN NIL; ./**************************************************************/FUNCTION IdentifyGlobal (tIdent) objectsi :- RETURN IdentifyLocal (i, genv->env.objects); ./**************************************************************/FUNCTION Identify (tIdent, envs) objectsi, env :- obj: objects; obj := IdentifyMember (i, env); obj != NIL; RETURN obj; .i, env (env := NIL) :- RETURN NIL; .i, env (env := env) ;i, env2 (env2 := env) :- RETURN Identify (i, env); .... :- RETURN NIL; ./**************************************************************/FUNCTION IdentifyMember (tIdent, envs) objectsident, env (env := env, objects := objects) :- obj: objects; obj := IdentifyLocal (ident, objects); obj != NIL; RETURN obj; .ident, env (env := env, objects := objects) :-
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -