Class: RubyUnderscore::AbstractSexp
- Inherits:
-
Object
- Object
- RubyUnderscore::AbstractSexp
show all
- Includes:
- EnhancerHelper
- Defined in:
- lib/tree_converters.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#assertSexpIs, #chain, #clone, #needsEnhancing, #sexpEnhancingCount, #sexpNeedsEnhancing, #sexpOf
Constructor Details
#initialize(sexp, enhancer) ⇒ AbstractSexp
Returns a new instance of AbstractSexp.
88
89
90
91
92
93
|
# File 'lib/tree_converters.rb', line 88
def initialize(sexp, enhancer)
assertSexpIs sexp, type
@sexp = sexp
@enhancer = enhancer
deconstruct sexp[1..-1]
end
|
Instance Attribute Details
#enhancer ⇒ Object
Returns the value of attribute enhancer.
85
86
87
|
# File 'lib/tree_converters.rb', line 85
def enhancer
@enhancer
end
|
#sexp ⇒ Object
Returns the value of attribute sexp.
85
86
87
|
# File 'lib/tree_converters.rb', line 85
def sexp
@sexp
end
|
Instance Method Details
#argumentList ⇒ Object
130
131
132
|
# File 'lib/tree_converters.rb', line 130
def argumentList
args[1]
end
|
#asArray ⇒ Object
143
144
145
|
# File 'lib/tree_converters.rb', line 143
def asArray
raise "subclass responsibility"
end
|
#deconstruct(sexp) ⇒ Object
135
136
137
|
# File 'lib/tree_converters.rb', line 135
def deconstruct(sexp)
raise "subclass responsibility"
end
|
#decVcallCount ⇒ Object
113
114
115
|
# File 'lib/tree_converters.rb', line 113
def decVcallCount
enhancer.vcallCount -= 1
end
|
#enhance ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/tree_converters.rb', line 117
def enhance
count = sexpEnhancingCount args
return regularEnhance unless count > 0
enhancer.vcallCount = count if enhancer.vcallCount.nil?
self.args = process args
if enhancer.vcallCount == 0
enhancer.vcallCount = nil
end
return regularEnhance unless subtreeNeedsEnhance?
decVcallCount
s :iter, s(*asArray), s(:dasgn_curr, enhancer.variableName), argumentList
end
|
#process(arg) ⇒ Object
99
100
101
|
# File 'lib/tree_converters.rb', line 99
def process(arg)
enhancer.process arg
end
|
#regularEnhance ⇒ Object
103
104
105
106
107
|
# File 'lib/tree_converters.rb', line 103
def regularEnhance
params = asArray
params.push(process(args)) if args
s *params
end
|
#s(*args) ⇒ Object
95
96
97
|
# File 'lib/tree_converters.rb', line 95
def s(*args)
enhancer.s *args
end
|
#subtreeNeedsEnhance? ⇒ Boolean
109
110
111
|
# File 'lib/tree_converters.rb', line 109
def subtreeNeedsEnhance?
enhancer.vcallCount && enhancer.vcallCount > 0
end
|
#type ⇒ Object
139
140
141
|
# File 'lib/tree_converters.rb', line 139
def type
raise "subclass responsibility"
end
|