Class: Rubex::AST::Expression::InstanceVar
- Inherits:
-
Base
- Object
- Base
- Rubex::AST::Expression::InstanceVar
show all
- Defined in:
- lib/rubex/ast/expression/instance_var.rb
Instance Attribute Summary
Attributes inherited from Base
#entry, #type, #typecast
Instance Method Summary
collapse
Methods inherited from Base
#allocate_temp, #allocate_temps, #analyse_for_target_type, #expression?, #from_ruby_object, #generate_and_dispose_subexprs, #generate_disposal_code, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object
Constructor Details
Returns a new instance of InstanceVar.
5
6
7
|
# File 'lib/rubex/ast/expression/instance_var.rb', line 5
def initialize(name)
@name = name
end
|
Instance Method Details
#analyse_types(local_scope) ⇒ Object
9
10
11
12
|
# File 'lib/rubex/ast/expression/instance_var.rb', line 9
def analyse_types(local_scope)
@type = DataType::RubyObject.new
@has_temp = true
end
|
#c_code(local_scope) ⇒ Object
25
26
27
28
29
|
# File 'lib/rubex/ast/expression/instance_var.rb', line 25
def c_code(local_scope)
code = super
code << @c_code
code
end
|
#generate_assignment_code(rhs, code, local_scope) ⇒ Object
19
20
21
22
23
|
# File 'lib/rubex/ast/expression/instance_var.rb', line 19
def generate_assignment_code(rhs, code, local_scope)
code << "rb_iv_set(#{local_scope.self_name}, \"#{@name}\","
code << "#{rhs.c_code(local_scope)});"
code.nl
end
|
#generate_evaluation_code(code, local_scope) ⇒ Object
14
15
16
17
|
# File 'lib/rubex/ast/expression/instance_var.rb', line 14
def generate_evaluation_code(code, local_scope)
code << "#{@c_code} = rb_iv_get(#{local_scope.self_name}, \"#{@name}\");"
code.nl
end
|