maroon 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,71 +0,0 @@
1
- class Self
2
-
3
- def initialize(abstract_syntax_tree,interpretationcontext)
4
- raise("Interpretation context missing") unless interpretationcontext
5
- unless interpretationcontext.defining_role then
6
- raise("Must have a defining role")
7
- end
8
- @abstract_syntax_tree = abstract_syntax_tree
9
- @interpretation_context = interpretationcontext
10
-
11
- end
12
-
13
- def execute()
14
- if abstract_syntax_tree then
15
- if (abstract_syntax_tree[0] == :self) then
16
- abstract_syntax_tree[0] = :call
17
- abstract_syntax_tree[1] = nil
18
- abstract_syntax_tree[2] = interpretation_context.defining_role
19
- else
20
- if (abstract_syntax_tree[0] == :call) and (abstract_syntax_tree[1] == nil) then
21
- method_name = abstract_syntax_tree[2]
22
- if ((method_name == :[]) or (method_name == :[]=)) then
23
- get_role = Sexp.new
24
- get_role[0] = :call
25
- get_role[1] = nil
26
- get_role[2] = interpretation_context.defining_role
27
- abstract_syntax_tree[1] = get_role
28
- end
29
- else
30
- if abstract_syntax_tree.instance_of?(Sexp) then
31
- if self_abstract_syntax_tree_is_indexer_call_on_self then
32
- getter = new(Sexp.new)
33
- getter[0] = :call
34
- getter[1] = nil
35
- getter[2] = interpretation_context.defining_role
36
- arglist = Sexp.new
37
- getter[3] = arglist
38
- arglist[0] = :arglist
39
- abstract_syntax_tree[1] = getter
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
46
-
47
- def self.call(*args)
48
- arity = Self.method(:new).arity
49
- newArgs = args[0..arity-1]
50
- obj = Self.new *newArgs
51
- if arity < args.length
52
- methodArgs = args[arity..-1]
53
- obj.execute *methodArgs
54
- else
55
- obj.execute
56
- end
57
- end
58
-
59
- def call(*args);execute *args; end
60
-
61
- private
62
- attr_reader :abstract_syntax_tree
63
- attr_reader :interpretation_context
64
-
65
-
66
- def self_abstract_syntax_tree_is_indexer_call_on_self()
67
- (abstract_syntax_tree.length == 4) and ((abstract_syntax_tree[0] == :call) and ((abstract_syntax_tree[1] == nil) and ((abstract_syntax_tree[2] == :[]) and (abstract_syntax_tree[3][0] == :argslist))))
68
- end
69
-
70
-
71
- end