Class: IDL::AST::Leaf
- Inherits:
-
Object
- Object
- IDL::AST::Leaf
- Defined in:
- lib/ridl/node.rb
Direct Known Subclasses
Attribute, Const, Enum, Enumerator, Initializer, Member, Node, Parameter, Port, StateMember, TemplateModuleReference, TemplateParam, Typedef, Valuebox
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#enclosure ⇒ Object
Returns the value of attribute enclosure.
-
#intern ⇒ Object
readonly
Returns the value of attribute intern.
-
#lm_name ⇒ Object
readonly
Returns the value of attribute lm_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
Instance Method Summary collapse
- #_set_prefix(pfx) ⇒ Object
- #has_annotations? ⇒ Boolean
-
#initialize(_name, _enclosure) ⇒ Leaf
constructor
A new instance of Leaf.
- #instantiate(_context, _enclosure, _params = {}) ⇒ Object
- #is_local? ⇒ Boolean
- #is_template? ⇒ Boolean
- #lm_name_for_scope ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(vars) ⇒ Object
- #parsed_name_scope ⇒ Object
- #replace_prefix(pfx) ⇒ Object
- #repo_scopes ⇒ Object
- #repository_id ⇒ Object
- #resolve(_name) ⇒ Object
- #scoped_lm_name ⇒ Object
- #scoped_name ⇒ Object
- #set_repo_id(id) ⇒ Object
- #set_repo_version(ma, mi) ⇒ Object
- #typename ⇒ Object
Constructor Details
#initialize(_name, _enclosure) ⇒ Leaf
Returns a new instance of Leaf.
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ridl/node.rb', line 104 def initialize(_name, _enclosure) _name ||= '' _name = IDL::Scanner::Identifier.new(_name, _name) unless IDL::Scanner::Identifier === _name @name = _name @lm_name = self.class.mk_name(_name.checked_name, _enclosure.nil? ? false : _enclosure.scopes.size>0).freeze @intern = _name.rjust(1).downcase.intern @enclosure = _enclosure @scopes = if @enclosure.nil? then [] else (@enclosure.scopes.dup << self) end @prefix = '' @repo_id = nil @repo_ver = nil @annotations = Annotations.new end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
98 99 100 |
# File 'lib/ridl/node.rb', line 98 def annotations @annotations end |
#enclosure ⇒ Object
Returns the value of attribute enclosure.
95 96 97 |
# File 'lib/ridl/node.rb', line 95 def enclosure @enclosure end |
#intern ⇒ Object (readonly)
Returns the value of attribute intern.
93 94 95 |
# File 'lib/ridl/node.rb', line 93 def intern @intern end |
#lm_name ⇒ Object (readonly)
Returns the value of attribute lm_name.
94 95 96 |
# File 'lib/ridl/node.rb', line 94 def lm_name @lm_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
93 94 95 |
# File 'lib/ridl/node.rb', line 93 def name @name end |
#prefix ⇒ Object
Returns the value of attribute prefix.
97 98 99 |
# File 'lib/ridl/node.rb', line 97 def prefix @prefix end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
96 97 98 |
# File 'lib/ridl/node.rb', line 96 def scopes @scopes end |
Instance Method Details
#_set_prefix(pfx) ⇒ Object
212 213 214 |
# File 'lib/ridl/node.rb', line 212 def _set_prefix(pfx) @prefix = pfx.to_s end |
#has_annotations? ⇒ Boolean
228 229 230 |
# File 'lib/ridl/node.rb', line 228 def has_annotations?() !@annotations.empty? end |
#instantiate(_context, _enclosure, _params = {}) ⇒ Object
152 153 154 |
# File 'lib/ridl/node.rb', line 152 def instantiate(_context, _enclosure, _params = {}) (_context[self] = self.class.new(self.name, _enclosure, _params)).copy_from(self, _context) end |
#is_local? ⇒ Boolean
236 237 238 |
# File 'lib/ridl/node.rb', line 236 def is_local? false end |
#is_template? ⇒ Boolean
148 149 150 |
# File 'lib/ridl/node.rb', line 148 def is_template? @enclosure && @enclosure.is_template? end |
#lm_name_for_scope ⇒ Object
122 123 124 |
# File 'lib/ridl/node.rb', line 122 def lm_name_for_scope lm_name end |
#marshal_dump ⇒ Object
134 135 136 |
# File 'lib/ridl/node.rb', line 134 def marshal_dump [@name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations] end |
#marshal_load(vars) ⇒ Object
138 139 140 141 142 |
# File 'lib/ridl/node.rb', line 138 def marshal_load(vars) @name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations = vars @scoped_name = nil @scoped_lm_name = nil end |
#parsed_name_scope ⇒ Object
118 119 120 |
# File 'lib/ridl/node.rb', line 118 def parsed_name_scope (@enclosure ? @enclosure.parsed_name_scope : '') + '::' + @name end |
#replace_prefix(pfx) ⇒ Object
208 209 210 |
# File 'lib/ridl/node.rb', line 208 def replace_prefix(pfx) self.prefix = pfx end |
#repo_scopes ⇒ Object
144 145 146 |
# File 'lib/ridl/node.rb', line 144 def repo_scopes @repo_scopes ||= (@enclosure.nil? ? [] : (@enclosure.repo_scopes.dup << self)) end |
#repository_id ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/ridl/node.rb', line 216 def repository_id if @repo_id.nil? @repo_ver = "1.0" unless @repo_ver format("IDL:%s%s:%s", if @prefix.empty? then "" else @prefix+"/" end, self.repo_scopes.collect{|s| s.name}.join("/"), @repo_ver) else @repo_id end end |
#resolve(_name) ⇒ Object
232 233 234 |
# File 'lib/ridl/node.rb', line 232 def resolve(_name) nil end |
#scoped_lm_name ⇒ Object
130 131 132 |
# File 'lib/ridl/node.rb', line 130 def scoped_lm_name @scoped_lm_name ||= @scopes.collect{|s| s.lm_name_for_scope }.join("::").freeze end |
#scoped_name ⇒ Object
126 127 128 |
# File 'lib/ridl/node.rb', line 126 def scoped_name @scoped_name ||= @scopes.collect{|s| s.name}.join("::").freeze end |
#set_repo_id(id) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/ridl/node.rb', line 156 def set_repo_id(id) if @repo_id if id != @repo_id raise RuntimeError, "#{self.scoped_name} already has a different repository ID assigned: #{@repo_id}" end end id_arr = id.split(':') if @repo_ver if id_arr.first != 'IDL' or id_arr.last != @repo_ver raise RuntimeError, "supplied repository ID (#{id}) does not match previously assigned repository version for #{self.scoped_name} = #{@repo_ver}" end end # check validity of IDL format repo IDs if id_arr.first == 'IDL' id_arr.shift id_str = id_arr.shift.to_s raise RuntimeError, 'ID identifiers should not start or end with \'/\'' if id_str[0,1]=='/' or id_str[-1, 1]=='/' raise RuntimeError, "ID identifiers should not start with one of '#{REPO_ID_XCHARS.join("', '")}'" if REPO_ID_XCHARS.include?(id_str[0,1]) raise RuntimeError, 'Invalid ID! Only a..z, A..Z, 0..9, \'.\', \'-\', \'_\' or \'\/\' allowed for identifiers' unless REPO_ID_RE =~ id_str end @repo_id = id end |
#set_repo_version(ma, mi) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ridl/node.rb', line 181 def set_repo_version(ma, mi) ver = "#{ma}.#{mi}" if @repo_ver if ver != @repo_ver raise RuntimeError, "#{self.scoped_name} already has a repository version assigned: #{@repo_ver}" end end if @repo_id l = @repo_id.split(':') if l.last != ver raise RuntimeError, "supplied repository version (#{ver}) does not match previously assigned repository ID for #{self.scoped_name}: #{@repo_id}" end end @repo_ver = ver end |
#typename ⇒ Object
100 101 102 |
# File 'lib/ridl/node.rb', line 100 def typename self.class.name end |