Преглед изворни кода

Remove makeForm(). Use Closure.fixed property to change assert/refute closures into a special forms.

master
Ian Piumarta пре 1 година
родитељ
комит
4a3abfc8c1
2 измењених фајлова са 57 додато и 5 уклоњено
  1. +53
    -3
      test.ref
  2. +4
    -2
      test.txt

+ 53
- 3
test.ref Прегледај датотеку

@ -12,7 +12,18 @@ Point.new(x: 3, y: 4) => <>
| y: 4
| x: 3
twice 21 is 42
double => <closure>
double => <<Closure>>
| environment: nil
| function: <<Lambda>>
| | body: <<Object>>
| | | 0: <<Binop>>
| | | | operation: 13
| | | | 0: <<GetVar>>
| | | | | name: x
| | | | 1: <<GetVar>>
| | | | | name: x
| | parameters: <<Object>>
| | | 0: x
Point.new(x:3, y:4).magnitude() => 5.000000
<<?>>
| self: nil =>
@ -50,7 +61,7 @@ ok
----
MyType.__eval__() invoked
42
<closure>
<<Closure>>
====
42
hello
@ -130,7 +141,44 @@ f 102 ( 40 ) 41 32 { 123 32 p 112 r 114 i 105 n 110 t 116 ( 40 _ 95 _ 95 e 1
42
6 * 7
MACRO table <<Object>>
| test: <closure>
| test: <<Closure>>
| | environment: nil
| | function: <<Lambda>>
| | | body: <<Object>>
| | | | 0: <<Call>>
| | | | | arguments: <<Object>>
| | | | | | 0: MACRO EVAL test with
| | | | | | 1: <<GetVar>>
| | | | | | | name: x
| | | | | | 2: and
| | | | | | 3: <<GetVar>>
| | | | | | | name: y
| | | | | | 4:
| | | | | function: <<GetVar>>
| | | | | | name: print
| | | | 1: <<Unyop>>
| | | | | operation: 3
| | | | | 0: <<Block>>
| | | | | | body: <<Object>>
| | | | | | | 0: <<Call>>
| | | | | | | | arguments: <<Object>>
| | | | | | | | | 0: REPLACEMENT
| | | | | | | | | 1: <<Unyop>>
| | | | | | | | | | operation: 4
| | | | | | | | | | 0: <<GetVar>>
| | | | | | | | | | | name: x
| | | | | | | | | 2:
| | | | | | | | function: <<GetVar>>
| | | | | | | | | name: print
| | | | | | | 1: <<Unyop>>
| | | | | | | | operation: 4
| | | | | | | | 0: <<GetVar>>
| | | | | | | | | name: y
| | | parameters: <<Object>>
| | | | 0: x
| | | | 1: y
define testfun
MACRO EVAL test with 1 and 2
MACRO EVAL test with three and four
@ -142,6 +190,8 @@ REPLACEMENT three
0 1 2 3 4 5 6 7 8 9
65 66 67 68 69
1 two 3 four
test.txt:331: *: illegal operand types Integer and String
11: n * factorial(n - 1)
10: if (n < 2) "1" else n * factorial(n - 1)
9: factorial(n - 1)

+ 4
- 2
test.txt Прегледај датотеку

@ -97,7 +97,7 @@ assert(x) {
}
}
makeForm(assert);
assert.fixed = #t; // do not evaluate arguments (x will be an AST suitable for eval())
refute(x) {
if (eval(x)) {
@ -106,7 +106,9 @@ refute(x) {
}
}
makeForm(refute);
refute.fixed = #t;
refute;
assert(1 == 1);
refute(1 == 0);

Loading…
Откажи
Сачувај