if( "$construct".equals(name) )
{
return; // ISSUE: experiment. don't define traits for constructors
}
IntList namespaces = new IntList(quals.size()); // will be (*it)->namespaces
Iterator<ObjectValue> i = quals.keySet().iterator();
boolean isInterface = (obj.type != null && obj.type.isInterface());
while (i.hasNext())
{
ObjectValue ns = i.next();
int slot_kind = kind==TRAIT_Setter?SET_TOKEN:GET_TOKEN;
int slot_index = obj.getSlotIndex(cx,slot_kind,name,ns);
Slot slot = obj.getSlot(cx,slot_index);
if( kind == TRAIT_Method )
{
int implicit_index = obj.getImplicitIndex(cx,slot_index,EMPTY_TOKEN);
slot = obj.getSlot(cx,implicit_index);
}
if( slot == null || slot.declaredBy != obj || slot.getMethodName().length() == 0 ) // this happens with internal accessors, that are not traits
{
continue;
}
ObjectValue slot_value = slot != null? (slot.getValue() instanceof ObjectValue ? (ObjectValue) slot.getValue() : null) : null;
ArrayList<MetaData> metaData = slot.getMetadata();
// If a name is interface-qualified, emit the trait only if the traits
// are for an interface definition. In a class, the VM will automatically
// add the interface-qualified traits when it sees the public method definition.
if (!isInterface && ns.isInterface())
{
continue;
}
boolean is_override = slot.isOverride();
int flags = 0; // final/virtual & 1, override/new & 2
flags |= slot.isFinal() ?TRAIT_FLAG_final:0/*virtual*/;
flags |= is_override?TRAIT_FLAG_override:0/*new*/;
if( ns != null )
{
int ns_index;
if (doingAPIVersioning) {
TreeSet<Integer> versions = apiVersionsOfSlot(slot, name, ns);
ns_index = makeVersionedNamespaceSet(ns, versions);
}
else {
ns_index = addNamespace(ns);
}
namespaces.add(ns_index);
}
else
{
cx.internalError(pos, "internal error: non object value for namespace");
}
int method_info = -1;
int method_id = slot.getMethodID();
if( method_id >= 0 )
{ // method
method_info = GetMethodInfo(slot.getMethodName());
}
else
if( slot_value != null && slot_value.method_info >= 0 )
{ // function
method_info = slot_value.method_info;
}
else
{
cx.internalError("internal error");
continue;
}
int name_index = ab.addUtf8Constant(bytecodeFactory.ConstantUtf8Info(name));
int qname_index;
if (doingAPIVersioning) {
qname_index = ab.addMultiNameConstant(bytecodeFactory.ConstantMultiname(name_index,namespaces.back(),false));
}
else {
qname_index = ab.addMultiNameConstant(bytecodeFactory.ConstantQualifiedName(name_index,namespaces.back(),false));
}
IntList metaDataIndices = addMetadata(metaData);
if( method_info >= 0 )
{
traits.push_back(allocBytes());
method_id = method_id<0?0:method_id; // ISSUE: normalize -1 to 0. refactor to make rest of compiler use 0