Exemplo n.º 1
0
        public override INamed getRegistered(string name)
        {
            if (widgetFields != null)
            {
                WidgetField field = null;
                if (widgetFields.TryGetValue(name, out field))
                {
                    return(field);
                }
            }
            INamed actual = base.getRegistered(name);

            if (actual != null)
            {
                return(actual);
            }
            ConcreteCategoryDeclaration decl    = getDeclaration();
            MethodDeclarationMap        methods = decl.getMemberMethods(this, name);

            if (methods != null && methods.Count > 0)
            {
                return(methods);
            }
            else if (decl.hasAttribute(this, name))
            {
                return(getRegisteredDeclaration <AttributeDeclaration>(name));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        private ISet <IMethodDeclaration> findMemberCandidates(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() == null)
            {
                // if called from a member method, could be a member method called without this/self
                InstanceContext instance = context.getClosestInstanceContext();
                if (instance != null)
                {
                    IType type = instance.getInstanceType();
                    ConcreteCategoryDeclaration cd = context.getRegisteredDeclaration <ConcreteCategoryDeclaration>(type.GetTypeName());
                    if (cd != null)
                    {
                        MethodDeclarationMap members = cd.getMemberMethods(context, selector.getName());
                        if (members != null)
                        {
                            return(new HashSet <IMethodDeclaration>(members.Values));
                        }
                    }
                }
                return(new HashSet <IMethodDeclaration>());
            }
            else
            {
                IType parentType = selector.checkParentType(context, checkInstance);
                return(parentType != null?parentType.getMemberMethods(context, selector.getName()) : new HashSet <IMethodDeclaration>());
            }
        }
Exemplo n.º 3
0
 public ConcreteInstance(Context context, ConcreteCategoryDeclaration declaration)
     : base(new CategoryType(declaration.GetName()))
 {
     this.declaration = declaration;
     if (declaration.Storable)
     {
         List <String> categories = declaration.CollectCategories(context);
         storable = DataStore.Instance.NewStorable(categories, new DbIdFactory(this));
     }
 }
Exemplo n.º 4
0
        private IDeclaration resolveUnresolvedMember(InstanceContext context, String name)
        {
            ConcreteCategoryDeclaration decl    = context.getRegisteredDeclaration <ConcreteCategoryDeclaration>(context.getInstanceType().GetTypeName());
            MethodDeclarationMap        methods = decl.getMemberMethods(context, name);

            if (methods != null && methods.Count > 0)
            {
                return(methods);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 public override T getRegisteredDeclaration <T>(string name)
 {
     if (typeof(T) == typeof(MethodDeclarationMap))
     {
         ConcreteCategoryDeclaration decl = getDeclaration();
         if (decl != null)
         {
             MethodDeclarationMap methods = decl.getMemberMethods(this, name);
             if (methods != null && methods.Count > 0)
             {
                 return(TypeUtils.downcast <T>(methods));
             }
         }
     }
     return(base.getRegisteredDeclaration <T>(name));
 }
Exemplo n.º 6
0
        protected override IValue readValue(String name, Func <IValue> supplier)
        {
            ConcreteCategoryDeclaration decl = getDeclaration();

            if (decl.hasAttribute(this, name))
            {
                IValue value = instance.GetMemberValue(calling, name, false);
                return(value != null ? value : supplier.Invoke());
            }
            else if (decl.hasMethod(this, name))
            {
                IMethodDeclaration method = decl.getMemberMethods(this, name).GetFirst();
                return(new ClosureValue(this, new MethodType(method)));
            }
            else
            {
                return(supplier.Invoke());
            }
        }
Exemplo n.º 7
0
        public override void register(Context context)
        {
            INamed actual = context.getRegisteredValue <INamed>(name);

            if (actual != null)
            {
                throw new SyntaxError("Duplicate argument: \"" + name + "\"");
            }
            ConcreteCategoryDeclaration declaration = new ConcreteCategoryDeclaration(name);

            declaration.setDerivedFrom(new IdentifierList(type.GetTypeName()));
            declaration.setAttributes(attributes);
            context.registerDeclaration(declaration);
            context.registerValue(this);
            if (DefaultValue != null)
            {
                IValue value = DefaultValue.interpret(context);
                context.setValue(name, value);
            }
        }
Exemplo n.º 8
0
        public override Context contextForValue(String name)
        {
            // params and variables have precedence over members
            // so first look in context values
            Context context = base.contextForValue(name);

            if (context != null)
            {
                return(context);
            }
            ConcreteCategoryDeclaration decl = getDeclaration();

            if (decl.hasAttribute(this, name) || decl.hasMethod(this, name))
            {
                return(this);
            }
            else
            {
                return(null);
            }
        }