예제 #1
0
        private Context newLocalInstanceContext(Context context, IMethodDeclaration declaration)
        {
            InstanceContext instance = context.getClosestInstanceContext();

            if (instance != null)
            {
                CategoryType required = (CategoryType)declaration.getMemberOf().GetIType(context);
                IType        actual   = instance.getInstanceType();
                if (!required.isAssignableFrom(context, actual))
                {
                    instance = null;
                }
            }
            if (instance == null)
            {
                CategoryType declaring = (CategoryType)declaration.getMemberOf().GetIType(context);
                instance = context.newInstanceContext(declaring, false);
            }
            return(instance.newChildContext());
        }
예제 #2
0
 public Context newLocalCheckContext(Context context, IMethodDeclaration declaration)
 {
     if (parent != null)
     {
         return(newInstanceCheckContext(context));
     }
     else if (declaration.getMemberOf() != null)
     {
         return(newLocalInstanceContext(context, declaration));
     }
     else
     {
         return(context.newLocalContext());
     }
 }
예제 #3
0
        private IMethodDeclaration getClosureDeclaration(Context context, ClosureValue closure)
        {
            IMethodDeclaration decl = closure.Method;

            if (decl.getMemberOf() != null)
            {
                // the closure references a member method (useful when a method reference is needed)
                // in which case we may simply want to return that method to avoid spilling context into method body
                // this is only true if the closure comes straight from the method's instance context
                // if the closure comes from an accessible context that is not the instance context
                // then it is a local variable that needs the closure context to be interpreted
                Context declaring = context.contextForValue(selector.getName());
                if (declaring == closure.getContext())
                {
                    return(decl);
                }
            }
            return(new ClosureDeclaration(closure)); throw new NotImplementedException();
        }
예제 #4
0
        private void checkAbstractOnly(Context context, IMethodDeclaration declaration)
        {
            if (declaration.IsReference()) // parameter or variable populated from a method call
            {
                return;
            }
            if (declaration.getMemberOf() != null) // the category could be subclassed (if constructor called on abstract, that would raise an error anyway)
            {
                return;
            }
            // if a global method, need to check for runtime dispatch
            MethodFinder finder = new MethodFinder(context, this);
            ISet <IMethodDeclaration> potential = finder.findPotential();

            if (potential.All(decl => decl.isAbstract()))
            {
                throw new SyntaxError("Cannot call abstract method: " + declaration.getSignature(Dialect.O));
            }
        }
예제 #5
0
 public CategoryDeclaration getMemberOf()
 {
     return(wrapped.getMemberOf());
 }