Class: IDL::AST::Leaf
- Inherits:
-
Object
show all
- 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
Instance Method Summary
collapse
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
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
Returns the value of attribute intern.
93
94
95
|
# File 'lib/ridl/node.rb', line 93
def intern
@intern
end
|
#lm_name ⇒ Object
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
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
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
216
217
218
|
# File 'lib/ridl/node.rb', line 216
def _set_prefix(pfx)
@prefix = pfx.to_s
end
|
#has_annotations? ⇒ Boolean
232
233
234
|
# File 'lib/ridl/node.rb', line 232
def has_annotations?()
!@annotations.empty?
end
|
#instantiate(_context, _enclosure, _params = {}) ⇒ Object
156
157
158
|
# File 'lib/ridl/node.rb', line 156
def instantiate(_context, _enclosure, _params = {})
(_context[self] = self.class.new(self.name, _enclosure, _params)).copy_from(self, _context)
end
|
#is_local? ⇒ Boolean
240
241
242
|
# File 'lib/ridl/node.rb', line 240
def is_local?
false
end
|
#is_template? ⇒ Boolean
152
153
154
|
# File 'lib/ridl/node.rb', line 152
def is_template?
@enclosure && @enclosure.is_template?
end
|
#lm_name_for_scope ⇒ Object
126
127
128
|
# File 'lib/ridl/node.rb', line 126
def lm_name_for_scope
lm_name
end
|
#marshal_dump ⇒ Object
138
139
140
|
# File 'lib/ridl/node.rb', line 138
def marshal_dump
[@name, @lm_name, @intern, @enclosure, @scopes, @prefix, @repo_id, @repo_ver, @annotations]
end
|
#marshal_load(vars) ⇒ Object
142
143
144
145
146
|
# File 'lib/ridl/node.rb', line 142
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
122
123
124
|
# File 'lib/ridl/node.rb', line 122
def parsed_name_scope
(@enclosure ? @enclosure.parsed_name_scope : '') + '::' + @name
end
|
#replace_prefix(pfx) ⇒ Object
212
213
214
|
# File 'lib/ridl/node.rb', line 212
def replace_prefix(pfx)
self.prefix = pfx
end
|
#repo_scopes ⇒ Object
148
149
150
|
# File 'lib/ridl/node.rb', line 148
def repo_scopes
@repo_scopes ||= (@enclosure.nil? ? [] : (@enclosure.repo_scopes.dup << self))
end
|
#repository_id ⇒ Object
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/ridl/node.rb', line 220
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
236
237
238
|
# File 'lib/ridl/node.rb', line 236
def resolve(_name)
nil
end
|
#scoped_lm_name ⇒ Object
134
135
136
|
# File 'lib/ridl/node.rb', line 134
def scoped_lm_name
@scoped_lm_name ||= @scopes.collect{|s| s.lm_name_for_scope }.join('::').freeze
end
|
#scoped_name ⇒ Object
130
131
132
|
# File 'lib/ridl/node.rb', line 130
def scoped_name
@scoped_name ||= @scopes.collect{|s| s.name}.join("::").freeze
end
|
#set_repo_id(id) ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/ridl/node.rb', line 160
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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/ridl/node.rb', line 185
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
|
#unescaped_name ⇒ Object
118
119
120
|
# File 'lib/ridl/node.rb', line 118
def unescaped_name
@name.unescaped_name
end
|