package ovm.core.domain;

import ovm.core.repository.Selector;
import ovm.core.repository.TypeName;
import ovm.core.repository.UnboundSelector;
import ovm.util.OVMException;

/**
 * FIXME revise this class, check the semantics, access rules etc
 **/
public interface MemberResolver {

    ResolutionInfo resolvePublicVirtualMethod(Blueprint bpt,
					      UnboundSelector.Method sel);
    
    ResolutionInfo resolveVirtualMethod(Blueprint bpt,
					UnboundSelector.Method sel,
					Type.Compound accessSite)
	throws IllegalAccessException;
    
    
    ResolutionInfo resolveInterfaceMethod(Blueprint bpt,
					  UnboundSelector.Method sel);
    
    ResolutionInfo resolveStaticMethod(Blueprint target,
				       UnboundSelector.Method sel,
				       Type accessSite);
    
    Method resolveStaticMethod(Type.Compound target,
			       UnboundSelector.Method sel,
			       Type accessSite);
    
    Method resolveInstanceMethod(Type.Compound target,
				 UnboundSelector.Method sel,
				 Type accessSite);

    Field resolveStaticField(Type.Class target,
		             UnboundSelector.Field sel,
			     Type accessSite);


    Field resolveInstanceField(Type.Class target,
			       UnboundSelector.Field sel,
			       Type.Compound callSite);

    
    // private and constructor methods (?)
    ResolutionInfo resolveSpecialMethod(Blueprint bpt,
					Selector.Method sel,
					Type.Compound callSite);



    public class IllegalAccessException extends OVMException.IllegalAccess {
        private final UnboundSelector what;
        private final TypeName.Compound where;
        private final TypeName.Compound target;
        public IllegalAccessException(TypeName.Compound target,
                                      UnboundSelector what,
                                      TypeName.Compound where) {
            this.what = what;
            this.where = where;
            this.target = target;
        }
        public String getMessage() {
            return what  + " in " + target
                + " is not accessible from " + where;
        }
    }


}
