Class: Pione::Lang::Variable

Inherits:
Expr
  • Object
show all
Defined in:
lib/pione/lang/variable.rb

Overview

Note:

Be careful variable are not treated as a sequence, because sequence is a concept of elements joined by sequencial operators and the receivers should be evaluated.

Variable is a model for variable name objects that have name string and package id. We use this for getting its value from variable table in the environment.

Instance Method Summary collapse

Methods inherited from Expr

inherited, pione_type, set_pione_type, #to_s

Methods included from Util::Positionable

#line_and_column, #pos, #set_source_position

Instance Method Details

#<=>(other) ⇒ Object

Compare with other variable.

Raises:

  • (ArgumentError)


40
41
42
43
# File 'lib/pione/lang/variable.rb', line 40

def <=>(other)
  raise ArgumentError.new(other) unless other.kind_of?(self.class)
  name <=> other.name
end

#element_type(env) ⇒ Object



22
23
24
# File 'lib/pione/lang/variable.rb', line 22

def element_type(env)
  env.variable_get(self).element_type(env)
end

#eval(env) ⇒ Object

Get the value from variable table in the environment.



27
28
29
# File 'lib/pione/lang/variable.rb', line 27

def eval(env)
  env.variable_get(self)
end

#eval!(env) ⇒ Object



31
32
33
# File 'lib/pione/lang/variable.rb', line 31

def eval!(env)
  eval(env).eval!(env)
end

#index_type(env) ⇒ Object



18
19
20
# File 'lib/pione/lang/variable.rb', line 18

def index_type(env)
  env.variable_get(self).index_type(env)
end

#pione_type(env) ⇒ Object



14
15
16
# File 'lib/pione/lang/variable.rb', line 14

def pione_type(env)
  env.variable_get(self).pione_type(env)
end

#textizeObject



35
36
37
# File 'lib/pione/lang/variable.rb', line 35

def textize
  ("$%s" % name) + (package_id ? "@%s" % package_id : "")
end