// Instance info
AbcData.InstanceInfo iinfo = this.abcData.getInstanceInfo(classID);
AbcData.BinaryMN instanceMN = getBinaryMNFromCPool(iinfo.getInstanceNameID());
QName fullName = getFullName(instanceMN);
String fullNameString = fullName.toString();
int superID = iinfo.getSuperID();
boolean hasSuper = superID != 0;
QName superName = null;
String simpleSuperName ="";
ObjectValue superNamespace = null;
if( hasSuper )
{
AbcData.BinaryMN superMN = getBinaryMNFromCPool(superID);
assert (superMN.nsIsSet != true):"expected a single namespace";
superNamespace = getNamespace(superMN.nsID);
superName = getFullName(superMN);
simpleSuperName = getStringFromCPool(superMN.nameID);
}
int flags = iinfo.getFlags();
int[] interfaces = iinfo.getInterfaces();
ListNode interface_nodes = null;
if(debug&&interfaces.length>0) System.out.println("parsing " + interfaces);
for( int i = 0; i < interfaces.length; ++i )
{
int int_index = interfaces[i];
AbcData.BinaryMN intMN = getBinaryMNFromCPool(int_index);
String simpleIntName = getStringFromCPool(intMN.nameID);
Namespaces intNamespaces;
if(intMN.nsIsSet)
intNamespaces = getNamespaces(intMN.nsID);
else {
intNamespaces = new Namespaces(1);
intNamespaces.add(getNamespace(intMN.nsID));
}
IdentifierNode ident = nf.identifier(simpleIntName);
ident.ref = new ReferenceValue(ctx, null, simpleIntName, intNamespaces);
GetExpressionNode getNode = nf.getExpression(ident);
MemberExpressionNode interface_node = nf.memberExpression(null, getNode);
interface_node.ref = ident.ref;
interface_nodes = nf.list(interface_nodes, interface_node);
interface_nodes.values.push_back(ident.ref);
}
boolean isFinal = (flags & ActionBlockConstants.CLASS_FLAG_final) != 0;
boolean isDynamic = ( flags & ActionBlockConstants.CLASS_FLAG_sealed ) == 0;
boolean isInterface = (flags & ActionBlockConstants.CLASS_FLAG_interface) != 0;
ClassDefinitionNode cdn = null;
IdentifierNode idNode = nf.identifier(className);
idNode.ref = new ReferenceValue(ctx, null, idNode.name, ns);
AttributeListNode attr = attributeList(isFinal, false, isDynamic, ns, current_scope.builder);
StatementListNode stmtList = nf.statementList(null, (StatementListNode)null);
if (isInterface)
{
cdn = nf.binaryInterfaceDefinition(ctx, attr, idNode, null, stmtList);
}
else
{
cdn = nf.binaryClassDefinition(ctx, attr, idNode, null, stmtList);
}
cdn.ref = idNode.ref;
cdn.interfaces = interface_nodes;
cdn.public_namespace = ctx.publicNamespace();
cdn.protected_namespace = ctx.getNamespace(fullNameString, Context.NS_PROTECTED);
cdn.static_protected_namespace = ctx.getNamespace(fullNameString, Context.NS_STATIC_PROTECTED);
cdn.private_namespace = ctx.getNamespace(fullNameString, Context.NS_PRIVATE);
cdn.default_namespace = ctx.getNamespace(fullName.ns.name, Context.NS_INTERNAL);
boolean is_builtin = ctx.isBuiltin(fullNameString);
TypeValue cframe;
ObjectValue iframe;
if( is_builtin )
{
cframe = ctx.builtin(fullNameString);
iframe = cframe.prototype;
}
else
{
ClassBuilder cb = new ClassBuilder(fullName,cdn.protected_namespace,cdn.static_protected_namespace);
cframe = TypeValue.defineTypeValue(ctx,cb,fullName,RuntimeConstants.TYPE_object);
InstanceBuilder ib = new InstanceBuilder(fullName);
ib.canEarlyBind = false;
iframe = new ObjectValue(ctx,ib,cframe);
cframe.prototype = iframe;
cdn.debug_name = fullNameString;
// Make sure the ClassBuilder and InstanceBuilders get cleaned up
cdn.owns_cframe = true;
}
cdn.cframe = cframe;
cdn.iframe = iframe;
if( isInterface )
{
((ClassBuilder)cframe.builder).is_interface = true;
}
cframe.builder.is_dynamic = iframe.builder.is_dynamic = isDynamic;
cframe.builder.is_final = iframe.builder.is_final = isFinal;
clsdefs_sets.last().add(cdn);
if( hasSuper )
{
TypeValue superType;
cdn.baseclass = nf.literalString(superName.toString(), -1);
if( ctx.isBuiltin(superName.toString()) )
{
// Set the super type, this important for int/uint which derive from Number
superType = ctx.builtin(superName.toString());
cframe.baseclass = superType;
cdn.baseref = new ReferenceValue(ctx, null, superName.toString(), ctx.publicNamespace());
}
else
{
//cdn.baseclass = nf.literalString(superName.toString(), -1);
cdn.baseref = new ReferenceValue(ctx, null, simpleSuperName, superNamespace);