Class: Mirah::AST::ScopedBody

Inherits:
Body
  • Object
show all
Includes:
Scope, Scoped
Defined in:
lib/mirah/ast/structure.rb,
lib/mirah/compiler/structure.rb

Instance Attribute Summary

Attributes included from Scope

#static_scope, #type_scope

Attributes inherited from Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

Methods included from Scoped

#containing_scope, #scope

Methods inherited from Body

#<<, #add_node, #expr?, #initialize, #string_value

Methods inherited from Node

#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children

Constructor Details

This class inherits a constructor from Mirah::AST::Body

Instance Method Details

#binding_type(mirah = nil) ⇒ Object



98
99
100
# File 'lib/mirah/ast/structure.rb', line 98

def binding_type(mirah=nil)
  static_scope.binding_type(defining_class, mirah)
end

#binding_type=(type) ⇒ Object



102
103
104
# File 'lib/mirah/ast/structure.rb', line 102

def binding_type=(type)
  static_scope.binding_type = type
end

#compile(compiler, expression) ⇒ Object



28
29
30
31
32
33
# File 'lib/mirah/compiler/structure.rb', line 28

def compile(compiler, expression)
  compiler.line(line_number)
  compiler.scoped_body(self, expression)
rescue Exception => ex
  raise Mirah::InternalCompilerError.wrap(ex, self)
end

#has_binding?Boolean

Returns:



106
107
108
# File 'lib/mirah/ast/structure.rb', line 106

def has_binding?
  static_scope.has_binding?
end

#infer(typer, expression) ⇒ Object



93
94
95
96
# File 'lib/mirah/ast/structure.rb', line 93

def infer(typer, expression)
  static_scope.self_type ||= typer.self_type
  super
end

#inspect_children(indent = 0) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/mirah/ast/structure.rb', line 115

def inspect_children(indent=0)
  indent_str = ' ' * indent
  str = ''
  if static_scope.self_node
    str << "\n#{indent_str}self: "
    if Node === static_scope.self_node
      str << "\n" << static_scope.self_node.inspect(indent + 1)
    else
      str << static_scope.self_node.inspect
    end
  end
  str << "\n#{indent_str}body:" << super(indent + 1)
end

#type_reference(typer) ⇒ Object

Raises:



110
111
112
113
# File 'lib/mirah/ast/structure.rb', line 110

def type_reference(typer)
  raise Mirah::SyntaxError.new("Invalid type", self) unless children.size == 1
  children[0].type_reference(typer)
end