Class: OCL::IterBlock
Instance Method Summary
collapse
Methods inherited from Block
check_condition, result, #to_s
Constructor Details
#initialize(iterator, expression) ⇒ IterBlock
Returns a new instance of IterBlock.
290
291
292
293
|
# File 'lib/dbc/ocl.rb', line 290
def initialize(iterator, expression)
@iterator = iterator
@expression = expression
end
|
Instance Method Details
#cexp? ⇒ Boolean
294
295
296
|
# File 'lib/dbc/ocl.rb', line 294
def cexp?
false
end
|
#to_cexp ⇒ Object
297
298
299
|
# File 'lib/dbc/ocl.rb', line 297
def to_cexp
raise "cannot convert #{self.class} to C expression"
end
|
#to_exp(result, indent_str = '') ⇒ Object
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
# File 'lib/dbc/ocl.rb', line 300
def to_exp(result, indent_str = '')
str = ''
str << self.initialize_iterator(result, indent_str)
str << indent_str << "{\n"
indent = "\t" << indent_str if @expression.cexp?
check_exp = @expression.to_cexp
inside_iterator = ''
else
check_exp = Block.result
str << indent << "int #{check_exp} = 0;\n"
inside_iterator = @expression.to_exp(check_exp, "\t" << indent)
end
str << @iterator.declare(indent)
str << @iterator.open(indent)
str << inside_iterator
str << self.check_iteration(check_exp, result, indent)
str << @iterator.close(indent)
str << indent_str << "}\n"
end
|