Class: IDL::AST::Const
Overview
Finder
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#idltype ⇒ Object
readonly
Returns the value of attribute idltype.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Leaf
#annotations, #enclosure, #intern, #name, #prefix, #scopes
Instance Method Summary collapse
-
#initialize(_name, _enclosure, params) ⇒ Const
constructor
A new instance of Const.
- #instantiate(instantiation_context, _enclosure) ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(vars) ⇒ Object
Methods inherited from Leaf
#has_annotations?, #is_local?, #is_template?, #lm_name, #lm_scopes, #replace_prefix, #repository_id, #resolve, #scoped_lm_name, #scoped_name, #set_repo_id, #set_repo_version, #typename, #unescaped_name
Constructor Details
#initialize(_name, _enclosure, params) ⇒ Const
Returns a new instance of Const.
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 |
# File 'lib/ridl/node.rb', line 2204 def initialize(_name, _enclosure, params) super(_name, _enclosure) @idltype = params[:type] @expression = params[:expression] @value = nil unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam) raise "Anonymous type definitions are not allowed!" if @idltype.is_anonymous? raise "Incomplete type #{@idltype.typename} not allowed here!" unless @idltype.is_complete? unless @expression.is_a?(IDL::Expression::ScopedName) && @expression.is_node?(IDL::AST::TemplateParam) @value = @idltype.narrow(@expression.value) end end end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
2202 2203 2204 |
# File 'lib/ridl/node.rb', line 2202 def expression @expression end |
#idltype ⇒ Object (readonly)
Returns the value of attribute idltype.
2202 2203 2204 |
# File 'lib/ridl/node.rb', line 2202 def idltype @idltype end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
2202 2203 2204 |
# File 'lib/ridl/node.rb', line 2202 def value @value end |
Instance Method Details
#instantiate(instantiation_context, _enclosure) ⇒ Object
2234 2235 2236 2237 2238 2239 2240 |
# File 'lib/ridl/node.rb', line 2234 def instantiate(instantiation_context, _enclosure) _params = { type: @idltype.instantiate(instantiation_context), expression: @expression.instantiate(instantiation_context) } super(instantiation_context, _enclosure, _params) end |
#marshal_dump ⇒ Object
2219 2220 2221 |
# File 'lib/ridl/node.rb', line 2219 def marshal_dump super() << @idltype << @expression end |
#marshal_load(vars) ⇒ Object
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 |
# File 'lib/ridl/node.rb', line 2223 def marshal_load(vars) @expression = vars.pop @idltype = vars.pop super(vars) unless @idltype.is_a?(IDL::Type::ScopedName) && @idltype.is_node?(IDL::AST::TemplateParam) unless @expression.is_a?(IDL::Expression::ScopedName) && @expression.is_node?(IDL::AST::TemplateParam) @value = @idltype.narrow(@expression.value) end end end |