maroon 0.7.0 → 0.7.1
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.
- checksums.yaml +4 -4
- data/Test/Context_test.rb +42 -11
- data/Test/{production_test.rb → abstract_syntax_tree_test.rb} +8 -3
- data/base/{Production.rb → AbstractSyntaxTree.rb} +15 -5
- data/base/AstRewritter.rb +48 -37
- data/base/maroon_base.rb +52 -165
- data/base/transfomer.rb +197 -0
- data/generated/build.rb +2 -2
- data/generated/interpretation_context.rb +7 -1
- data/lib/AstRewritter.rb +41 -31
- data/lib/Context.rb +44 -116
- data/lib/ImmutableQueue.rb +0 -1
- data/lib/ImmutableStack.rb +2 -1
- data/lib/Production.rb +20 -6
- data/lib/Transformer.rb +174 -0
- data/lib/build.rb +3 -3
- data/lib/interpretation_context.rb +7 -1
- data/lib/maroon/version.rb +1 -1
- metadata +6 -7
- data/Test/MethodInfo_test.rb +0 -86
- data/base/method_info.rb +0 -67
- data/lib/MethodInfo.rb +0 -66
data/lib/MethodInfo.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
class MethodInfo
|
2
|
-
def initialize(ast, defining_role, is_private)
|
3
|
-
raise("Must be S-Expressions") unless ast.instance_of?(Sexp)
|
4
|
-
@defining_role = defining_role
|
5
|
-
@private = is_private
|
6
|
-
@definition = ast
|
7
|
-
self.freeze
|
8
|
-
end
|
9
|
-
|
10
|
-
def is_private()
|
11
|
-
@private
|
12
|
-
end
|
13
|
-
|
14
|
-
def name()
|
15
|
-
self_definition_name
|
16
|
-
end
|
17
|
-
|
18
|
-
def build_as_context_method(interpretation_context)
|
19
|
-
AstRewritter.new(self_definition_body, interpretation_context).rewrite!
|
20
|
-
body = Ruby2Ruby.new.process(self_definition_body)
|
21
|
-
raise("Body is undefined") unless body
|
22
|
-
args = self_definition_arguments
|
23
|
-
if args and args.length then
|
24
|
-
args = (("(" + args.join(",")) + ")")
|
25
|
-
else
|
26
|
-
args = ""
|
27
|
-
end
|
28
|
-
real_name = (
|
29
|
-
if (@defining_role == nil) then
|
30
|
-
name.to_s
|
31
|
-
else
|
32
|
-
((("self_" + @defining_role.to_s) + "_") + name.to_s)
|
33
|
-
end).to_s
|
34
|
-
header = (("def " + real_name) + args)
|
35
|
-
(((header + " ") + body) + " end\n")
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
attr_reader :definition
|
40
|
-
|
41
|
-
def self_definition_body()
|
42
|
-
args = definition.detect { |d| (d[0] == :args) }
|
43
|
-
index = (definition.index(args) + 1)
|
44
|
-
if (definition.length > (index + 1)) then
|
45
|
-
body = definition[(index..-1)]
|
46
|
-
body.insert(0, :block)
|
47
|
-
body
|
48
|
-
else
|
49
|
-
definition[index]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def self_definition_arguments()
|
54
|
-
args = definition.detect { |d| (d[0] == :args) }
|
55
|
-
args and (args.length > 1) ? (args[(1..-1)]) : ([])
|
56
|
-
end
|
57
|
-
|
58
|
-
def self_definition_name()
|
59
|
-
if definition[1].instance_of?(Symbol) then
|
60
|
-
definition[1]
|
61
|
-
else
|
62
|
-
((definition[1].select { |e| e.instance_of?(Symbol) }.map { |e| e.to_s }.join(".") + ".") + definition[2].to_s).to_sym
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|