Class: Pione::Lang::Expr

Inherits:
StructX
  • Object
show all
Includes:
Util::Positionable
Defined in:
lib/pione/lang/expr.rb

Overview

Expr is a base class for all PIONE expressions.

Direct Known Subclasses

Message, Sequence, Variable

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Positionable

#line_and_column, #pos, #set_source_position

Class Method Details

.inherited(subclass) ⇒ Object



19
20
21
22
23
# File 'lib/pione/lang/expr.rb', line 19

def inherited(subclass)
  if @pione_type
    subclass.set_pione_type(@pione_type)
  end
end

.pione_type(env = nil) ⇒ Object

Set pione model type of the model.



10
11
12
# File 'lib/pione/lang/expr.rb', line 10

def pione_type(env=nil)
  @pione_type
end

.set_pione_type(type) ⇒ Object



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

def set_pione_type(type)
  @pione_type = type
  Type.table[type.name][:sequence_class] = self
end

Instance Method Details

#eval(env) ⇒ Object



28
29
30
# File 'lib/pione/lang/expr.rb', line 28

def eval(env)
  return self
end

#eval!(env) ⇒ Object



32
33
34
# File 'lib/pione/lang/expr.rb', line 32

def eval!(env)
  return self
end

#textizeObject

Convert to text string.



37
38
39
40
41
42
# File 'lib/pione/lang/expr.rb', line 37

def textize
  args = to_h.map do |key, val|
    "%s: %s" % [key, val.kind_of?(Piece) ? val.textize : val.to_s]
  end.join(", ")
  "#%s{%s}" % [piece_classes.first.piece_type_name, args]
end

#to_sObject



44
45
46
# File 'lib/pione/lang/expr.rb', line 44

def to_s
  textize
end