2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2018-09-01 14:54:25 +02:00
|
|
|
# Send and yield are very very similar, so they have a base class CallStatement
|
|
|
|
#
|
|
|
|
# The SendStatement really only provides to_s, so see CallStatement
|
|
|
|
#
|
2018-07-30 13:44:14 +02:00
|
|
|
class SendStatement < CallStatement
|
2019-08-25 13:40:59 +02:00
|
|
|
|
2019-10-03 23:36:49 +02:00
|
|
|
def to_sol
|
2019-09-07 21:13:53 +02:00
|
|
|
if @receiver.is_a?(ModuleName) and @receiver.name == :X
|
2019-10-03 23:36:49 +02:00
|
|
|
args = @arguments.collect { |arg| arg.to_sol }
|
|
|
|
return Sol::MacroExpression.new(name , args)
|
2019-09-07 21:13:53 +02:00
|
|
|
end
|
|
|
|
return require_file if( @name == :require_relative )
|
|
|
|
return super
|
2019-08-25 13:40:59 +02:00
|
|
|
end
|
2019-08-16 13:09:56 +02:00
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth( depth , "#{receiver}.#{name}(#{arguments.join(', ')})")
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
2019-09-07 21:13:53 +02:00
|
|
|
def require_file
|
|
|
|
target = @arguments.first.value
|
|
|
|
if(target == 'helper')
|
|
|
|
file = "/test/rubyx/rt_parfait/helper.rb"
|
|
|
|
else
|
|
|
|
file = "/lib/parfait/#{target}.rb"
|
|
|
|
end
|
|
|
|
path = File.expand_path( "../../../#{file}" , __FILE__)
|
|
|
|
source = File.read(path)
|
2019-10-03 23:36:49 +02:00
|
|
|
RubyCompiler.compile( source ).to_sol
|
2019-09-07 21:13:53 +02:00
|
|
|
end
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
2019-08-19 17:48:13 +02:00
|
|
|
class SuperStatement < SendStatement
|
|
|
|
def initialize(args)
|
|
|
|
super(:super , SelfExpression.new , args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|