fancy 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +38 -86
- data/bin/fdoc +2 -22
- data/bin/fspec +8 -3
- data/bin/ifancy +1 -1
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/array.rb +19 -0
- data/boot/fancy_ext/class.rb +2 -4
- data/boot/fancy_ext/module.rb +2 -0
- data/boot/fancy_ext/object.rb +0 -17
- data/boot/rbx-compiler/compiler/ast/method_def.rb +0 -4
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +0 -7
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/fancy_parser.c +1 -0
- data/doc/api/fancy.css +10 -1
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +22 -9
- data/doc/api/octocat.png +0 -0
- data/doc/features.md +1 -2
- data/examples/actors.fy +1 -2
- data/examples/armstrong_numbers.fy +7 -3
- data/examples/blocks.fy +3 -3
- data/examples/distributing_proxy.fy +31 -0
- data/examples/future_sends.fy +15 -0
- data/examples/person.fy +1 -2
- data/lib/argv.fy +1 -7
- data/lib/array.fy +7 -11
- data/lib/block.fy +15 -0
- data/lib/boot.fy +4 -3
- data/lib/class.fy +354 -10
- data/lib/compiler.fy +1 -1
- data/lib/compiler/ast/assign.fy +4 -8
- data/lib/compiler/ast/async_send.fy +1 -2
- data/lib/compiler/ast/block.fy +5 -0
- data/lib/compiler/ast/class_def.fy +2 -1
- data/lib/compiler/ast/expression_list.fy +1 -2
- data/lib/compiler/ast/future_send.fy +1 -2
- data/lib/compiler/ast/identifier.fy +34 -17
- data/lib/compiler/ast/literals.fy +31 -19
- data/lib/compiler/ast/match.fy +5 -4
- data/lib/compiler/ast/message_send.fy +3 -5
- data/lib/compiler/ast/method_def.fy +0 -3
- data/lib/compiler/ast/range.fy +2 -4
- data/lib/compiler/ast/return.fy +2 -4
- data/lib/compiler/ast/script.fy +2 -4
- data/lib/compiler/ast/singleton_method_def.fy +0 -3
- data/lib/compiler/ast/string_interpolation.fy +2 -2
- data/lib/compiler/ast/super.fy +2 -4
- data/lib/compiler/ast/try_catch.fy +13 -9
- data/lib/compiler/ast/tuple_literal.fy +1 -2
- data/lib/compiler/compiler.fy +2 -2
- data/lib/compiler/stages.fy +3 -6
- data/lib/contracts.fy +89 -57
- data/lib/dynamic_slot_object.fy +21 -3
- data/lib/enumerable.fy +140 -4
- data/lib/enumerator.fy +1 -1
- data/lib/eval.fy +23 -9
- data/lib/exception.fy +16 -0
- data/lib/false_class.fy +36 -5
- data/lib/fancy_spec.fy +64 -34
- data/lib/fdoc.fy +85 -24
- data/lib/file.fy +19 -0
- data/lib/future.fy +4 -46
- data/lib/hash.fy +113 -0
- data/lib/integer.fy +25 -6
- data/lib/iteration.fy +3 -3
- data/lib/main.fy +5 -0
- data/lib/matchers.fy +79 -0
- data/lib/nil_class.fy +8 -0
- data/lib/object.fy +109 -18
- data/lib/option_parser.fy +118 -0
- data/lib/package/dependency.fy +4 -8
- data/lib/package/dependency_installer.fy +1 -1
- data/lib/package/handler.fy +6 -0
- data/lib/package/installer.fy +43 -16
- data/lib/package/list.fy +1 -2
- data/lib/package/specification.fy +5 -5
- data/lib/package/uninstaller.fy +9 -2
- data/lib/parser.fy +1 -3
- data/lib/parser/ext/ext.c +1 -0
- data/lib/parser/ext/lexer.lex +5 -0
- data/lib/parser/methods.fy +48 -46
- data/lib/proxies.fy +151 -0
- data/lib/rbx.fy +1 -0
- data/lib/rbx/actor.fy +16 -18
- data/lib/rbx/array.fy +18 -3
- data/lib/rbx/block.fy +1 -7
- data/lib/rbx/class.fy +54 -9
- data/lib/rbx/code_loader.fy +2 -5
- data/lib/rbx/compiled_method.fy +31 -0
- data/lib/rbx/debugger.fy +66 -0
- data/lib/rbx/directory.fy +8 -3
- data/lib/rbx/documentation.fy +1 -1
- data/lib/rbx/file.fy +22 -0
- data/lib/rbx/integer.fy +1 -1
- data/lib/rbx/match_data.fy +2 -1
- data/lib/rbx/method.fy +26 -0
- data/lib/rbx/object.fy +8 -3
- data/lib/rbx/regexp.fy +6 -3
- data/lib/rbx/string.fy +9 -1
- data/lib/rbx/stringio.fy +12 -0
- data/lib/rbx/symbol.fy +4 -0
- data/lib/stack.fy +1 -1
- data/lib/string.fy +34 -0
- data/lib/stringio.fy +1 -1
- data/lib/symbol.fy +6 -2
- data/lib/system.fy +15 -1
- data/lib/tuple.fy +5 -2
- data/lib/version.fy +1 -1
- data/ruby_lib/fdoc +2 -22
- data/tests/array.fy +3 -17
- data/tests/class.fy +312 -10
- data/tests/contracts.fy +51 -0
- data/tests/distributing_proxy.fy +28 -0
- data/tests/enumerable.fy +104 -1
- data/tests/exception.fy +35 -0
- data/tests/fixnum.fy +1 -1
- data/tests/hash.fy +81 -1
- data/tests/integer.fy +9 -0
- data/tests/matchers.fy +18 -0
- data/tests/method.fy +8 -14
- data/tests/object.fy +76 -2
- data/tests/option_parser.fy +80 -0
- data/tests/string.fy +21 -0
- data/tests/stringio.fy +1 -1
- data/tests/tuple.fy +1 -1
- metadata +21 -44
- data/examples/arithmetic.fy +0 -7
- data/examples/array.fy +0 -50
- data/examples/boolean.fy +0 -24
- data/examples/class.fy +0 -68
- data/examples/constant_access.fy +0 -15
- data/examples/default_args.fy +0 -20
- data/examples/define_methods.fy +0 -15
- data/examples/dynamic_output.fy +0 -15
- data/examples/empty_catch.fy +0 -4
- data/examples/exception.fy +0 -9
- data/examples/files.fy +0 -23
- data/examples/finally.fy +0 -5
- data/examples/future.fy +0 -30
- data/examples/future_composition.fy +0 -20
- data/examples/futures.fy +0 -9
- data/examples/game_of_life.fy +0 -148
- data/examples/html_generator.fy +0 -84
- data/examples/implicit_return.fy +0 -3
- data/examples/matchers.fy +0 -6
- data/examples/nested_try.fy +0 -9
- data/examples/numbers.fy +0 -12
- data/examples/rbx/and_or.fy +0 -7
- data/examples/rbx/blocks.fy +0 -22
- data/examples/rbx/classes.fy +0 -32
- data/examples/rbx/hello.fy +0 -8
- data/examples/rbx/include.fy +0 -12
- data/examples/rbx/inherit.fy +0 -11
- data/examples/rbx/methods.fy +0 -15
- data/examples/rbx/nested_classes.fy +0 -9
- data/examples/rbx/require.fy +0 -3
- data/examples/rbx/strings.fy +0 -5
- data/examples/require.fy +0 -7
- data/examples/return.fy +0 -13
- data/examples/singleton_methods.fy +0 -21
- data/examples/threads.fy +0 -18
- data/examples/tuple.fy +0 -8
- data/examples/webserver/webserver.fy +0 -15
- data/lib/proxy.fy +0 -86
- data/lib/thread_pool.fy +0 -102
data/lib/compiler.fy
CHANGED
data/lib/compiler/ast/assign.fy
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class Assignment : Node {
|
|
3
|
-
def initialize: @line var: @lvalue value: @rvalue
|
|
4
|
-
}
|
|
3
|
+
def initialize: @line var: @lvalue value: @rvalue
|
|
5
4
|
|
|
6
5
|
def bytecode: g {
|
|
7
6
|
pos(g)
|
|
@@ -11,8 +10,7 @@ class Fancy AST {
|
|
|
11
10
|
|
|
12
11
|
class MultipleAssignment : Node {
|
|
13
12
|
class MultipleAssignmentExpr : Node {
|
|
14
|
-
def initialize: @line index: @index
|
|
15
|
-
}
|
|
13
|
+
def initialize: @line index: @index
|
|
16
14
|
|
|
17
15
|
def bytecode: g {
|
|
18
16
|
pos(g)
|
|
@@ -24,8 +22,7 @@ class Fancy AST {
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
class SplatAssignmentExpr : Node {
|
|
27
|
-
def initialize: @line start_index: @start_index
|
|
28
|
-
}
|
|
25
|
+
def initialize: @line start_index: @start_index
|
|
29
26
|
|
|
30
27
|
def bytecode: g {
|
|
31
28
|
pos(g)
|
|
@@ -36,8 +33,7 @@ class Fancy AST {
|
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
def initialize: @line var: @idents value: @values
|
|
40
|
-
}
|
|
36
|
+
def initialize: @line var: @idents value: @values
|
|
41
37
|
|
|
42
38
|
def bytecode: g {
|
|
43
39
|
pos(g)
|
data/lib/compiler/ast/block.fy
CHANGED
|
@@ -5,14 +5,19 @@ class Fancy AST {
|
|
|
5
5
|
if: (@body empty?) then: {
|
|
6
6
|
@body unshift_expression: $ NilLiteral new: @line
|
|
7
7
|
}
|
|
8
|
+
|
|
8
9
|
initialize(@line, @args, @body)
|
|
10
|
+
|
|
9
11
|
@args create_locals: self
|
|
12
|
+
|
|
10
13
|
if: (@args total_args == 0) then: {
|
|
11
14
|
@arguments prelude=(nil)
|
|
12
15
|
}
|
|
16
|
+
|
|
13
17
|
if: (@args.total_args > 1) then: {
|
|
14
18
|
@arguments prelude=('multi)
|
|
15
19
|
}
|
|
20
|
+
|
|
16
21
|
@arguments required_args=(@args required_args)
|
|
17
22
|
|
|
18
23
|
if: @partial then: {
|
|
@@ -3,6 +3,7 @@ class Fancy AST {
|
|
|
3
3
|
def initialize: @line name: @name parent: @parent body: @body (ExpressionList new: @line) {
|
|
4
4
|
{ @body = ExpressionList new: @line } unless: @body
|
|
5
5
|
name = nil
|
|
6
|
+
|
|
6
7
|
if: (@name is_a?: NestedConstant) then: {
|
|
7
8
|
name = @name scoped
|
|
8
9
|
} else: {
|
|
@@ -19,7 +20,7 @@ class Fancy AST {
|
|
|
19
20
|
def bytecode: g {
|
|
20
21
|
pos(g)
|
|
21
22
|
docstring = body() body() docstring
|
|
22
|
-
docstring
|
|
23
|
+
if: docstring then: {
|
|
23
24
|
setdoc = MessageSend new: @line \
|
|
24
25
|
message: (Identifier from: "for:append:" line: @line) \
|
|
25
26
|
to: (Identifier from: "Fancy::Documentation" line: @line) \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class Identifier : Node {
|
|
3
|
-
read_slots:
|
|
3
|
+
read_slots: ('string, 'line)
|
|
4
4
|
read_write_slot: 'ruby_ident
|
|
5
5
|
|
|
6
6
|
@@gen_ident_start = 0
|
|
@@ -24,17 +24,17 @@ class Fancy AST {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
def name {
|
|
27
|
-
@string to_sym
|
|
27
|
+
@string to_sym
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
def method_name: receiver ruby_send: ruby (false) {
|
|
31
|
-
ruby || @ruby_ident
|
|
32
|
-
@string to_sym
|
|
31
|
+
if: (ruby || @ruby_ident) then: {
|
|
32
|
+
@string to_sym
|
|
33
33
|
} else: {
|
|
34
|
-
@string =~ /:$/
|
|
35
|
-
@string to_sym
|
|
34
|
+
if: (@string =~ /:$/) then: {
|
|
35
|
+
@string to_sym
|
|
36
36
|
} else: {
|
|
37
|
-
":" + @string . to_sym
|
|
37
|
+
":" + @string . to_sym
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -44,11 +44,12 @@ class Fancy AST {
|
|
|
44
44
|
case "__FILE__" -> return CurrentFile new: line filename: filename
|
|
45
45
|
case "__LINE__" -> return CurrentLine new: line
|
|
46
46
|
case "self" -> return Self new: line
|
|
47
|
+
case /^::/ -> ToplevelConstant
|
|
47
48
|
case /^[A-Z].*::/ -> NestedConstant
|
|
48
49
|
case /^[A-Z]/ -> Constant
|
|
49
50
|
case /^@@/ -> ClassVariable
|
|
50
51
|
case /^@/ -> InstanceVariable
|
|
51
|
-
case
|
|
52
|
+
case /^\*[a-zA-Z0-9_-]+\*$/ -> DynamicVariable
|
|
52
53
|
case _ -> Identifier
|
|
53
54
|
}
|
|
54
55
|
type new: line string: string
|
|
@@ -72,7 +73,7 @@ class Fancy AST {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
class InstanceVariable : Identifier {
|
|
75
|
-
def initialize: @line string: @string
|
|
76
|
+
def initialize: @line string: @string
|
|
76
77
|
def bytecode: g {
|
|
77
78
|
pos(g)
|
|
78
79
|
Rubinius AST InstanceVariableAccess new(@line, name) bytecode(g)
|
|
@@ -80,7 +81,7 @@ class Fancy AST {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
class ClassVariable : Identifier {
|
|
83
|
-
def initialize: @line string: @string
|
|
84
|
+
def initialize: @line string: @string
|
|
84
85
|
def bytecode: g {
|
|
85
86
|
pos(g)
|
|
86
87
|
Rubinius AST ClassVariableAccess new(@line, name) bytecode(g)
|
|
@@ -88,7 +89,7 @@ class Fancy AST {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
class Constant : Identifier {
|
|
91
|
-
def initialize: @line string: @string
|
|
92
|
+
def initialize: @line string: @string
|
|
92
93
|
def bytecode: g {
|
|
93
94
|
pos(g)
|
|
94
95
|
Rubinius AST ConstantAccess new(@line, name) bytecode(g)
|
|
@@ -96,19 +97,25 @@ class Fancy AST {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
class NestedConstant : Identifier {
|
|
99
|
-
def initialize: @line string: @string
|
|
100
|
-
}
|
|
100
|
+
def initialize: @line string: @string
|
|
101
101
|
|
|
102
102
|
def initialize: @line const: const parent: parent {
|
|
103
103
|
@string = (parent string) ++ "::" ++ (const string)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
def scoped {
|
|
107
|
-
names = @string split
|
|
108
|
-
parent =
|
|
107
|
+
names = @string split: "::"
|
|
108
|
+
parent = nil
|
|
109
|
+
match @string {
|
|
110
|
+
case /^::/ ->
|
|
111
|
+
names = names rest
|
|
112
|
+
parent = ToplevelConstant new: @line string: "::#{names shift}"
|
|
113
|
+
case _ ->
|
|
114
|
+
parent = Constant new: @line string: $ names shift
|
|
115
|
+
}
|
|
109
116
|
scoped = nil
|
|
110
|
-
names each
|
|
111
|
-
scoped = Rubinius AST ScopedConstant new(@line, parent, name to_sym
|
|
117
|
+
names each: |name| {
|
|
118
|
+
scoped = Rubinius AST ScopedConstant new(@line, parent, name to_sym)
|
|
112
119
|
parent = scoped
|
|
113
120
|
}
|
|
114
121
|
scoped
|
|
@@ -120,6 +127,16 @@ class Fancy AST {
|
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
|
|
130
|
+
class ToplevelConstant : Identifier {
|
|
131
|
+
def initialize: @line string: @string
|
|
132
|
+
|
|
133
|
+
def bytecode: g {
|
|
134
|
+
pos(g)
|
|
135
|
+
const_name = @string from: 2 to: -1 . to_sym # skip leading ::
|
|
136
|
+
Rubinius AST ToplevelConstant new(@line, const_name) . bytecode(g)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
123
140
|
class DynamicVariable : Identifier {
|
|
124
141
|
read_slot: 'varname
|
|
125
142
|
def initialize: @line string: @string {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class NilLiteral : Rubinius AST NilLiteral {
|
|
3
|
-
def initialize: line {
|
|
3
|
+
def initialize: line {
|
|
4
|
+
initialize(line)
|
|
5
|
+
}
|
|
4
6
|
def bytecode: g {
|
|
5
7
|
pos(g)
|
|
6
8
|
bytecode(g)
|
|
@@ -8,7 +10,9 @@ class Fancy AST {
|
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
class FixnumLiteral : Rubinius AST FixnumLiteral {
|
|
11
|
-
def initialize: line value: value {
|
|
13
|
+
def initialize: line value: value {
|
|
14
|
+
initialize(line, value)
|
|
15
|
+
}
|
|
12
16
|
def bytecode: g {
|
|
13
17
|
pos(g)
|
|
14
18
|
bytecode(g)
|
|
@@ -16,7 +20,9 @@ class Fancy AST {
|
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
class NumberLiteral : Rubinius AST NumberLiteral {
|
|
19
|
-
def initialize: line value: value {
|
|
23
|
+
def initialize: line value: value {
|
|
24
|
+
initialize(line, value)
|
|
25
|
+
}
|
|
20
26
|
def bytecode: g {
|
|
21
27
|
pos(g)
|
|
22
28
|
bytecode(g)
|
|
@@ -24,7 +30,9 @@ class Fancy AST {
|
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
class StringLiteral : Rubinius AST StringLiteral {
|
|
27
|
-
def initialize: line value: value {
|
|
33
|
+
def initialize: line value: value {
|
|
34
|
+
initialize(line, StringHelper unescape_string(value))
|
|
35
|
+
}
|
|
28
36
|
def bytecode: g {
|
|
29
37
|
pos(g)
|
|
30
38
|
bytecode(g)
|
|
@@ -32,19 +40,15 @@ class Fancy AST {
|
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
class CurrentFile : Node {
|
|
35
|
-
def initialize: @line filename: @filename
|
|
43
|
+
def initialize: @line filename: @filename
|
|
36
44
|
def bytecode: g {
|
|
37
45
|
pos(g)
|
|
38
|
-
|
|
39
|
-
MessageSend new: @line message: (Identifier from: "current_file:" line: @line) \
|
|
40
|
-
to: (Identifier from: "Fancy::CodeLoader" line: @line) \
|
|
41
|
-
args: args .
|
|
42
|
-
bytecode: g
|
|
46
|
+
StringLiteral new: @line value: $ File absolute_path: @filename . bytecode: g
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
class CurrentLine : Node {
|
|
47
|
-
def initialize: @line
|
|
51
|
+
def initialize: @line
|
|
48
52
|
def bytecode: g {
|
|
49
53
|
pos(g)
|
|
50
54
|
FixnumLiteral new: @line value: @line . bytecode: g
|
|
@@ -52,12 +56,12 @@ class Fancy AST {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
class Nothing : Node {
|
|
55
|
-
def initialize: @line
|
|
59
|
+
def initialize: @line
|
|
56
60
|
def bytecode: g { pos(g) }
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
class StackTop : Node {
|
|
60
|
-
def initialize: @line
|
|
64
|
+
def initialize: @line
|
|
61
65
|
def bytecode: g {
|
|
62
66
|
pos(g)
|
|
63
67
|
g dup()
|
|
@@ -65,8 +69,10 @@ class Fancy AST {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
class StackLocal : Node {
|
|
68
|
-
def initialize: @line
|
|
69
|
-
def set: g {
|
|
72
|
+
def initialize: @line
|
|
73
|
+
def set: g {
|
|
74
|
+
@local = g new_stack_local(); g set_stack_local(@local)
|
|
75
|
+
}
|
|
70
76
|
def bytecode: g {
|
|
71
77
|
pos(g)
|
|
72
78
|
g push_stack_local(@local)
|
|
@@ -74,7 +80,9 @@ class Fancy AST {
|
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
class Self : Rubinius AST Self {
|
|
77
|
-
def initialize: line {
|
|
83
|
+
def initialize: line {
|
|
84
|
+
initialize(line)
|
|
85
|
+
}
|
|
78
86
|
def bytecode: g {
|
|
79
87
|
pos(g)
|
|
80
88
|
bytecode(g)
|
|
@@ -90,7 +98,9 @@ class Fancy AST {
|
|
|
90
98
|
|
|
91
99
|
class SymbolLiteral : Rubinius AST SymbolLiteral {
|
|
92
100
|
read_slot: 'value
|
|
93
|
-
def initialize: line value: value {
|
|
101
|
+
def initialize: line value: value {
|
|
102
|
+
initialize(line, value)
|
|
103
|
+
}
|
|
94
104
|
def string {
|
|
95
105
|
value
|
|
96
106
|
}
|
|
@@ -101,7 +111,9 @@ class Fancy AST {
|
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
class RegexpLiteral : Rubinius AST RegexLiteral {
|
|
104
|
-
def initialize: line value: value {
|
|
114
|
+
def initialize: line value: value {
|
|
115
|
+
initialize(line, value, 0)
|
|
116
|
+
}
|
|
105
117
|
def bytecode: g {
|
|
106
118
|
pos(g)
|
|
107
119
|
bytecode(g)
|
|
@@ -109,7 +121,7 @@ class Fancy AST {
|
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
class ArrayLiteral : Rubinius AST ArrayLiteral {
|
|
112
|
-
|
|
124
|
+
read_slot: 'array
|
|
113
125
|
def initialize: line array: @array {
|
|
114
126
|
@array if_nil: { @array = [] }
|
|
115
127
|
initialize(line, @array)
|
data/lib/compiler/ast/match.fy
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class Match : Node {
|
|
3
|
-
def initialize: @line expr: @expr body: @clauses
|
|
4
|
-
}
|
|
3
|
+
def initialize: @line expr: @expr body: @clauses
|
|
5
4
|
|
|
6
5
|
def bytecode: g set_match_args: clause {
|
|
7
|
-
"
|
|
6
|
+
"""
|
|
7
|
+
Generates bytecode for setting match clause arguments, if needed.
|
|
8
|
+
"""
|
|
8
9
|
|
|
9
10
|
g dup()
|
|
10
11
|
skip_create_locals_label = g new_label()
|
|
@@ -94,7 +95,7 @@ class Fancy AST {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
class MatchClause : Node {
|
|
97
|
-
read_slots:
|
|
98
|
+
read_slots: ('expr, 'body, 'match_args)
|
|
98
99
|
|
|
99
100
|
def initialize: @line expr: @expr body: @body args: @match_args {
|
|
100
101
|
if: (@expr kind_of?: Identifier) then: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class MessageSend : Node {
|
|
3
|
-
read_write_slots:
|
|
3
|
+
read_write_slots: ('name, 'receiver, 'args)
|
|
4
4
|
|
|
5
5
|
# fast instructions to be used if possible
|
|
6
6
|
FastOps = <[
|
|
@@ -12,8 +12,7 @@ class Fancy AST {
|
|
|
12
12
|
':> => 'meta_send_op_gt
|
|
13
13
|
]>
|
|
14
14
|
|
|
15
|
-
def initialize: @line message: @name to: @receiver (Self new: @line) args: @args (MessageArgs new: @line)
|
|
16
|
-
}
|
|
15
|
+
def initialize: @line message: @name to: @receiver (Self new: @line) args: @args (MessageArgs new: @line);
|
|
17
16
|
|
|
18
17
|
def redirect_via: redirect_message {
|
|
19
18
|
message_name = SymbolLiteral new: @line value: (@name string to_sym)
|
|
@@ -96,8 +95,7 @@ class Fancy AST {
|
|
|
96
95
|
class MessageArgs : Node {
|
|
97
96
|
read_slot: 'args
|
|
98
97
|
|
|
99
|
-
def initialize: @line args: @args ([])
|
|
100
|
-
}
|
|
98
|
+
def initialize: @line args: @args ([]);
|
|
101
99
|
|
|
102
100
|
def bytecode: g {
|
|
103
101
|
pos(g)
|
data/lib/compiler/ast/range.fy
CHANGED
data/lib/compiler/ast/return.fy
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
class Fancy AST {
|
|
2
2
|
class Return : Node {
|
|
3
|
-
def initialize: @line expr: @expr
|
|
4
|
-
}
|
|
3
|
+
def initialize: @line expr: @expr
|
|
5
4
|
|
|
6
5
|
def bytecode: g {
|
|
7
6
|
pos(g)
|
|
@@ -11,8 +10,7 @@ class Fancy AST {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
class ReturnLocal : Node {
|
|
14
|
-
def initialize: @line expr: @expr
|
|
15
|
-
}
|
|
13
|
+
def initialize: @line expr: @expr
|
|
16
14
|
|
|
17
15
|
def bytecode: g {
|
|
18
16
|
pos(g)
|