Class: Chelsy::Declaration

Inherits:
Declarative show all
Defined in:
lib/chelsy/ast.rb

Overview

6.7 Declarations

Instance Attribute Summary collapse

Attributes inherited from Declarative

#storage

Attributes inherited from Element

#fragments, #post_fragments

Instance Method Summary collapse

Methods inherited from Declarative

#extern?, #static?

Constructor Details

#initialize(name, type, init = nil, **rest) ⇒ Declaration

Returns a new instance of Declaration.



1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
# File 'lib/chelsy/ast.rb', line 1105

def initialize(name, type, init=nil, **rest)
  @name = Syntax::Ident.ensure(name)
  @type = Syntax::Type.ensure(type)
  @init = case init
          when nil
            nil
          when Enumerable
            InitializerList.new(init)
          else
            Syntax::Expr.ensure(init)
          end

  super(**rest)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1103
1104
1105
# File 'lib/chelsy/ast.rb', line 1103

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



1103
1104
1105
# File 'lib/chelsy/ast.rb', line 1103

def type
  @type
end

Instance Method Details

#initObject



1120
# File 'lib/chelsy/ast.rb', line 1120

def init; @init end