1 |
|
2 |
|
3 | Eval_float = ->
|
4 | evaluatingAsFloats++
|
5 | push(cadr(p1))
|
6 | Eval()
|
7 | yyfloat()
|
8 | Eval();
|
9 | evaluatingAsFloats--
|
10 |
|
11 | checkFloatHasWorkedOutCompletely = (nodeToCheck) ->
|
12 | numberOfPowers = countOccurrencesOfSymbol(symbol(POWER),nodeToCheck)
|
13 | numberOfPIs = countOccurrencesOfSymbol(symbol(PI),nodeToCheck)
|
14 | numberOfEs = countOccurrencesOfSymbol(symbol(E),nodeToCheck)
|
15 | numberOfMults = countOccurrencesOfSymbol(symbol(MULTIPLY),nodeToCheck)
|
16 | numberOfSums = countOccurrencesOfSymbol(symbol(ADD),nodeToCheck)
|
17 | if DEBUG
|
18 | console.log " ... numberOfPowers: " + numberOfPowers
|
19 | console.log " ... numberOfPIs: " + numberOfPIs
|
20 | console.log " ... numberOfEs: " + numberOfEs
|
21 | console.log " ... numberOfMults: " + numberOfMults
|
22 | console.log " ... numberOfSums: " + numberOfSums
|
23 | if numberOfPowers > 1 or numberOfPIs > 0 or numberOfEs > 0 or numberOfMults > 1 or numberOfSums > 1
|
24 | stop("float: some unevalued parts in " + nodeToCheck)
|
25 |
|
26 | zzfloat = ->
|
27 | save()
|
28 | evaluatingAsFloats++
|
29 |
|
30 |
|
31 |
|
32 | Eval()
|
33 | yyfloat()
|
34 | Eval();
|
35 | evaluatingAsFloats--
|
36 | restore()
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | yyfloat = ->
|
45 | i = 0
|
46 | h = 0
|
47 | evaluatingAsFloats++
|
48 | save()
|
49 | p1 = pop()
|
50 | if (iscons(p1))
|
51 | h = tos
|
52 | while (iscons(p1))
|
53 | push(car(p1))
|
54 | yyfloat()
|
55 | p1 = cdr(p1)
|
56 | list(tos - h)
|
57 | else if (p1.k == TENSOR)
|
58 | push(p1)
|
59 | copy_tensor()
|
60 | p1 = pop()
|
61 | for i in [0...p1.tensor.nelem]
|
62 | push(p1.tensor.elem[i])
|
63 | yyfloat()
|
64 | p1.tensor.elem[i] = pop()
|
65 | push(p1)
|
66 | else if (p1.k == NUM)
|
67 | push(p1)
|
68 | bignum_float()
|
69 | else if (p1 == symbol(PI))
|
70 | push_double(Math.PI)
|
71 | else if (p1 == symbol(E))
|
72 | push_double(Math.E)
|
73 | else
|
74 | push(p1)
|
75 | restore()
|
76 | evaluatingAsFloats--
|
77 |
|