Class: Opal::Rewriters::OpalEngineCheck
- Inherits:
-
Base
- Object
- Parser::AST::Processor
- Base
- Opal::Rewriters::OpalEngineCheck
show all
- Defined in:
- opal/lib/opal/rewriters/opal_engine_check.rb
Constant Summary
- RUBY_ENGINE_CHECK =
s(:send, s(:const, nil, :RUBY_ENGINE),
:==, s(:str, "opal"))
- RUBY_ENGINE_CHECK_NOT =
s(:send, s(:const, nil, :RUBY_ENGINE),
:!=, s(:str, "opal"))
- RUBY_PLATFORM_CHECK =
s(:send, s(:const, nil, :RUBY_PLATFORM),
:==, s(:str, "opal"))
- RUBY_PLATFORM_CHECK_NOT =
s(:send, s(:const, nil, :RUBY_PLATFORM),
:!=, s(:str, "opal"))
Instance Method Summary
collapse
Methods inherited from Base
#append_to_body, #prepend_to_body, #s, s
Instance Method Details
#on_if(node) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'opal/lib/opal/rewriters/opal_engine_check.rb', line 7
def on_if(node)
test, true_body, false_body = *node.children
if skip_check_present?(test)
false_body = s(:nil)
end
if skip_check_present_not?(test)
true_body = s(:nil)
end
node.updated(nil, process_all([test, true_body, false_body]))
end
|
#skip_check_present?(test) ⇒ Boolean
#skip_check_present_not?(test) ⇒ Boolean