Repository navigation
Expand file tree
/
Copy pathclear.coffee
More file actions
87 lines (59 loc) · 1.64 KB
/
Copy pathclear.coffee
File metadata and controls
87 lines (59 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
### clearall =====================================================================
Tags
----
scripting, JS, internal, treenode, general concept
General description
-------------------
Completely wipes all variables from the environment.
###
Eval_clearall = ->
do_clearall()
push(symbol(NIL))
do_clearall = ->
if (test_flag == 0)
clear_term()
do_clearPatterns()
clear_symbols()
defn()
codeGen = false
# clearall from application GUI code
clearall = ->
run("clearall")
# this transformation is done in run.coffee, see there
# for more info.
clearRenamedVariablesToAvoidBindingToExternalScope = ->
for i in [0...symtab.length]
if symtab[i].printname.indexOf("AVOID_BINDING_TO_EXTERNAL_SCOPE_VALUE") != -1
# just clear it
symtab[i].k = SYM
symtab[i].printname = ""
binding[i] = symtab[i]
isSymbolReclaimable[i] = true
### clear =====================================================================
Tags
----
scripting, JS, internal, treenode, general concept
Parameters
----------
x
General description
-------------------
Completely wipes a variable from the environment (while doing x = quote(x) just unassigns it).
###
Eval_clear = ->
p2 = cdr(p1)
while (iscons(p2))
variableToBeCleared = car(p2)
#console.log variableToBeCleared + ""
if (variableToBeCleared.k != SYM)
stop("symbol error")
#console.log "getting binding of " + p.toString()
#if p.toString() == "aaa"
# debugger
indexFound = symtab.indexOf(variableToBeCleared)
symtab[indexFound].k = SYM
symtab[indexFound].printname = ""
binding[indexFound] = symtab[indexFound]
isSymbolReclaimable[indexFound] = true
p2 = cdr(p2)
push(symbol(NIL))