Class: IDL::AST::ComponentBase
Overview
Constant Summary
collapse
- DEFINABLE =
[]
Instance Attribute Summary collapse
Attributes inherited from Leaf
#annotations, #enclosure, #intern, #name, #prefix, #scopes
Instance Method Summary
collapse
Methods inherited from Derivable
#has_ancestor?, #search_self, #search_self_before_derived
Methods inherited from Node
#define, #introduce, #is_definable?, #match_members, #replace_prefix, #resolve, #select_members, #undo_introduction, #walk_members
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) ⇒ ComponentBase
Returns a new instance of ComponentBase.
1162
1163
1164
1165
1166
1167
1168
1169
1170
|
# File 'lib/ridl/node.rb', line 1162
def initialize(_name, _enclosure, params)
super(_name, _enclosure)
@base = nil
@resolved_base = nil
@interfaces = []
@resolved_interfaces = []
set_base(params[:base]) if params[:base]
add_interfaces(params[:supports] || [])
end
|
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
1160
1161
1162
|
# File 'lib/ridl/node.rb', line 1160
def base
@base
end
|
#idltype ⇒ Object
Returns the value of attribute idltype.
1160
1161
1162
|
# File 'lib/ridl/node.rb', line 1160
def idltype
@idltype
end
|
#interfaces ⇒ Object
Returns the value of attribute interfaces.
1160
1161
1162
|
# File 'lib/ridl/node.rb', line 1160
def interfaces
@interfaces
end
|
Instance Method Details
#add_interfaces(intfs) ⇒ Object
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
|
# File 'lib/ridl/node.rb', line 1216
def add_interfaces(intfs)
intfs.each do |tc|
unless tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::TemplateParam)
unless (tc.is_a?(IDL::Type::ScopedName) && tc.is_node?(IDL::AST::Interface))
raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{tc.typename}"
end
rtc = tc.resolved_type
unless rtc.node.is_defined?
raise "#{typename} #{scoped_lm_name} cannot support forward declared #{tc.node.typename} #{tc.node.scoped_lm_name}"
end
if rtc.node.is_local?
raise "#{typename} #{scoped_lm_name} cannot support 'local' #{tc.node.typename} #{tc.node.scoped_lm_name}"
end
if rtc.node.is_pseudo?
raise "#{typename} #{scoped_lm_name} cannot support 'pseudo' #{tc.node.typename} #{tc.node.scoped_lm_name}"
end
if self.has_support?(rtc.node)
raise "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} multiple times"
end
unless @resolved_interfaces.any? { |b| b.has_ancestor?(rtc.node) }
new_op_att_ = []
rtc.node.walk_members do |m|
new_op_att_ << m if m.is_a?(IDL::AST::Operation) || m.is_a?(IDL::AST::Attribute)
end
if new_op_att_.any? { |n| n_ = self.search_self(n.name)
n_.is_a?(IDL::AST::Operation) || n_.is_a?(IDL::AST::Attribute) }
raise "#{typename} #{scoped_lm_name} cannot support #{tc.node.typename} #{tc.node.scoped_lm_name} because of duplicated operations/attributes"
end
end
@resolved_interfaces << rtc.node
end
@interfaces << tc.node
end
end
|
#ancestors ⇒ Object
1212
1213
1214
|
# File 'lib/ridl/node.rb', line 1212
def ancestors
resolved_bases
end
|
#has_base?(n) ⇒ Boolean
1208
1209
1210
|
# File 'lib/ridl/node.rb', line 1208
def has_base?(n)
@resolved_base && (@resolved_base == n.idltype.resolved_type.node)
end
|
#has_support?(intf) ⇒ Boolean
1262
1263
1264
|
# File 'lib/ridl/node.rb', line 1262
def has_support?(intf)
@resolved_interfaces.any? { |b| b == intf.idltype.resolved_type.node }
end
|
#instantiate(instantiation_context, _enclosure, _params = {}) ⇒ Object
1185
1186
1187
1188
1189
1190
1191
1192
|
# File 'lib/ridl/node.rb', line 1185
def instantiate(instantiation_context, _enclosure, _params = {})
_params.merge!({
base: @base ? IDL::AST::TemplateParam.concrete_param(instantiation_context, @base) : @base,
supports: self.concrete_interfaces(instantiation_context)
})
super(instantiation_context, _enclosure, _params)
end
|
#marshal_dump ⇒ Object
1172
1173
1174
|
# File 'lib/ridl/node.rb', line 1172
def marshal_dump
super() << @base << @resolved_base << @interfaces << @resolved_interfaces << @idltype
end
|
#marshal_load(vars) ⇒ Object
1176
1177
1178
1179
1180
1181
1182
1183
|
# File 'lib/ridl/node.rb', line 1176
def marshal_load(vars)
@idltype = vars.pop
@resolved_interfaces = vars.pop
@interfaces = vars.pop
@resolved_base = vars.pop
@base = vars.pop
super(vars)
end
|
#redefine(node, params) ⇒ Object
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
|
# File 'lib/ridl/node.rb', line 1270
def redefine(node, params)
if node.enclosure == self
case node
when IDL::AST::Struct, IDL::AST::Union
if node.is_defined?
raise "#{node.typename} \"#{node.name}\" is already defined."
end
node.annotations.concat(params[:annotations])
_new_node = node.class.new(node.name, self, params)
_new_node.annotations.concat(node.annotations)
_new_node.prefix = node.prefix
_new_node.instance_variable_set(:@repo_ver, node.instance_variable_get(:@repo_ver))
_new_node.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id))
node.switchtype = params[:switchtype] if node.is_a?(IDL::AST::Union)
@children << _new_node
node.enclosure.undo_introduction(node)
introduce(_new_node)
return _new_node
else
raise "#{node.typename} \"#{node.name}\" is already defined."
end
end
case node
when IDL::AST::Operation, IDL::AST::Attribute
raise "#{node.typename} '#{node.scoped_lm_name}' cannot be overridden."
else
newnode = node.class.new(node.name, self, params)
newnode.annotations.concat(params[:annotations])
introduce(newnode)
@children << newnode
return newnode
end
end
|
#set_base(parent) ⇒ Object
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
|
# File 'lib/ridl/node.rb', line 1194
def set_base(parent)
unless parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(IDL::AST::TemplateParam)
unless (parent.is_a?(IDL::Type::NodeType) && parent.is_node?(self.class))
raise "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
end
if parent.resolved_type.node.has_base?(self)
raise "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
end
@resolved_base = parent.resolved_type.node
end
@base = parent.node
end
|
#supports?(intf) ⇒ Boolean
1266
1267
1268
|
# File 'lib/ridl/node.rb', line 1266
def supports?(intf)
self.has_support?(intf) || (@resolved_base && @resolved_base.supports?(intf)) || @resolved_interfaces.any? { |base_i| i.has_ancestor?(intf) }
end
|