Class: Mirah::AST::Regexp
- Includes:
- Literal
- Defined in:
- lib/mirah/ast/literal.rb,
lib/mirah/compiler/literal.rb
Instance Attribute Summary
Attributes included from Literal
Attributes included from Typed
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, line_number, literal) ⇒ Regexp
constructor
A new instance of Regexp.
Methods included from Literal
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, literal) ⇒ Regexp
Returns a new instance of Regexp.
71 72 73 74 |
# File 'lib/mirah/ast/literal.rb', line 71 def initialize(parent, line_number, literal) super(parent, line_number) @literal = literal end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/mirah/compiler/literal.rb', line 30 def compile(compiler, expression) if expression compiler.line(line_number) compiler.regexp(literal) end rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
76 77 78 79 80 |
# File 'lib/mirah/ast/literal.rb', line 76 def infer(typer, expression) return @inferred_type if resolved? resolved! @inferred_type ||= typer.regexp_type end |