Class: RbsMacros::ExecCtx
- Inherits:
-
Object
- Object
- RbsMacros::ExecCtx
- Defined in:
- lib/rbs_macros/exec_ctx.rb
Overview
Context, including self, class, and local variables
Instance Method Summary collapse
Instance Method Details
#eval_node(node) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rbs_macros/exec_ctx.rb', line 8 def eval_node(node) case node when nil # do nothing when Prism::CallNode recv = \ if node.receiver eval_node(node.receiver) else self.self end positional = [] # : Array[Object] keyword = {} # : Hash[Object, Object] node.arguments&.arguments&.each do |arg| positional << eval_node(arg) end env.invoke( Environment::HandlerParams.new( env:, filename:, receiver: recv, name: node.name, positional:, keyword:, block: nil ) ) when Prism::ClassNode klass = cref.define_module(node.name) klass.class! with( self: klass, cref: klass, cref_dynamic: klass, locals: {} ).eval_node(node.body) when Prism::ModuleNode mod = cref.define_module(node.name) mod.module! with( self: mod, cref: mod, cref_dynamic: mod, locals: {} ).eval_node(node.body) when Prism::ProgramNode eval_node(node.statements) when Prism::StatementsNode node.body.each { |stmt| eval_node(stmt) } when Prism::StringNode node.unescaped.dup.freeze when Prism::SymbolNode node.unescaped.to_sym else $stderr.puts "Dismissing node: #{node.inspect}" # rubocop:disable Style/StderrPuts end end |