/*
* $Id: CompiledInterfaceType.java,v 1.7 2002/09/16 08:05:04 jkl Exp $
*
* Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
*
* Use is subject to license terms, as defined in
* Anvil Sofware License, Version 1.1. See LICENSE
* file, or http://njet.org/license-1.1.txt
*/
package anvil.script.compiler;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Enumeration;
import anvil.core.Any;
import anvil.core.runtime.AnyType;
import anvil.core.runtime.AnyFunction;
import anvil.doc.Doc;
import anvil.script.Scope;
import anvil.script.CompilableFunction;
import anvil.script.ConstantVariableType;
import anvil.script.Type;
import anvil.script.MethodType;
import anvil.script.InterfaceType;
import anvil.script.InterfaceRef;
import anvil.java.util.Hashlist;
/**
* class CompiledInterfaceType
*
* @author: Jani Lehtim�ki
*/
public class CompiledInterfaceType extends CompiledScope implements InterfaceType
{
protected InterfaceRef[] _bases;
public CompiledInterfaceType(ClassLoader classloader, Scope parent, Class cls, String name, Doc document)
{
super(parent, cls, name, document);
try {
String[] bases = (String[])getstatic(cls, "_bases");
int n = bases.length;
_bases = new InterfaceRef[n];
for(int i=0; i<n; i++) {
Class icls = classloader.loadClass(bases[i]);
_bases[i] = new DelayedInterfaceRef(icls);
}
putstatic(cls, "_class", this);
putstatic(cls, "_type", new AnyType(this));
} catch (Exception e) {
anvil.Log.log().error("Interface initialization failed: "+cls.getName(), e);
}
initializeMembers(classloader);
}
public int getType()
{
return INTERFACE;
}
public InterfaceRef[] getBases()
{
return _bases;
}
public Type lookupDeclaration(String name)
{
Type type = (Type)_types.get(name);
if (type == null) {
return lookupInheritedDeclaration(name);
} else {
return type;
}
}
public Type lookupInheritedDeclaration(String name)
{
Type type;
InterfaceRef[] bases = _bases;
InterfaceType interfacetype;
int n = bases.length;
for(int i=0; i<n; i++) {
type = bases[i].getInterfaceType().lookupDeclaration(name);
if (type != null) {
return type;
}
}
return null;
}
}