Class: Nydp::Invocation::Base
- Includes:
- Helper
- Defined in:
- lib/nydp/function_invocation.rb
Overview
def self.whazzup
puts @@sig_counts.to_a.sort_by { |c| c[1] }.map { |c| "#{c[1]}\t#{c[0]}"}
end
Direct Known Subclasses
Invocation_1, Invocation_2, Invocation_3, Invocation_4, Invocation_LEX, Invocation_LEX_LEX, Invocation_LEX_LEX_LEX, Invocation_N, Invocation_SYM, Invocation_SYM_LEX, Invocation_SYM_LEX_LEX, Invocation_SYM_LEX_LEX_LEX, Invocation_SYM_LEX_LIT_LEX, Invocation_SYM_LIT, Invocation_SYM_LIT_LEX
Instance Method Summary collapse
- #handle(e, f, invoker, *args) ⇒ Object
-
#initialize(expr, source, sig = nil) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
-
#lexical_reach(n) ⇒ Object
TODO: speed up compilation by writing custom #lexical_reach for sig-based subclasses (when you know which elements of #expr are lexical symbols).
- #source ⇒ Object
- #to_s ⇒ Object
Methods included from Helper
#cons, #list, #literal?, #pair?, #sig, #sym, #sym?
Methods included from Converter
Constructor Details
#initialize(expr, source, sig = nil) ⇒ Base
Returns a new instance of Base.
16 17 18 |
# File 'lib/nydp/function_invocation.rb', line 16 def initialize expr, source, sig=nil @expr, @source, @sig = expr, source, sig end |
Instance Method Details
#handle(e, f, invoker, *args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nydp/function_invocation.rb', line 20 def handle e, f, invoker, *args case e when Nydp::Error, InvocationFailed raise else if e.is_a?(NoMethodError) && !f.respond_to?(invoker) raise InvocationFailed.new("#{f.inspect} is not a function: args were #{args.inspect} in #{source.inspect}") else msg = args.map { |a| " #{a.inspect}"}.join("\n") msg = "failed to execute invocation #{f.inspect}\n#{msg}" msg += "\nsource was #{source.inspect}" msg += "\nfunction name was #{source.car.inspect}" raise InvocationFailed.new msg end end end |
#inspect ⇒ Object
42 |
# File 'lib/nydp/function_invocation.rb', line 42 def inspect ; @expr.map { |x| x.inspect }.join(' ') ; end |
#lexical_reach(n) ⇒ Object
TODO: speed up compilation by writing custom #lexical_reach for sig-based subclasses (when you know which elements of #expr are lexical symbols)
38 39 40 |
# File 'lib/nydp/function_invocation.rb', line 38 def lexical_reach n @expr.map { |x| x.lexical_reach n}.max end |
#source ⇒ Object
43 |
# File 'lib/nydp/function_invocation.rb', line 43 def source ; @source ; end |
#to_s ⇒ Object
44 |
# File 'lib/nydp/function_invocation.rb', line 44 def to_s ; source.to_s ; end |