Esempio n. 1
0
 public IType checkAttribute(Context context, CategoryDeclaration decl, String name)
 {
     if (decl.Storable && "dbId" == name)
     {
         return(AnyType.Instance);
     }
     else if (decl.hasAttribute(context, name))
     {
         AttributeDeclaration ad = context.getRegisteredDeclaration <AttributeDeclaration>(name);
         if (ad == null)
         {
             throw new SyntaxError("Unknown atttribute:" + name);
         }
         else
         {
             return(ad.GetIType(context));
         }
     }
     else if ("text" == name)
     {
         return(TextType.Instance);
     }
     else if (decl.hasMethod(context, name))
     {
         IMethodDeclaration method = decl.getMemberMethods(context, name).GetFirst();
         return(new MethodType(method));
     }
     else
     {
         throw new SyntaxError("No attribute:" + name + " in category:" + GetTypeName());
     }
 }
Esempio n. 2
0
        public override Comparer <IValue> getComparer(Context context, IExpression key, bool descending)
        {
            if (key == null)
            {
                key = new UnresolvedIdentifier("key", Dialect.E);
            }
            IDeclaration d = getDeclaration(context);

            if (d is CategoryDeclaration)
            {
                CategoryDeclaration decl = (CategoryDeclaration)d;
                if (decl.hasAttribute(context, key.ToString()))
                {
                    return(new AttributeComparer(context, key.ToString(), descending));
                }
                else if (decl.hasMethod(context, key.ToString()))
                {
                    return(new CategoryMethodComparer(context, key.ToString(), descending));
                }
                else if (globalMethodExists(context, key.ToString())) // TODO support 2 args
                {
                    return(new GlobalMethodComparer(context, key.ToString(), descending, this));
                }
                else if (key is ArrowExpression)
                {
                    return(((ArrowExpression)key).GetComparer(context, this, descending));
                }
                else
                {
                    return(new ExpressionComparer(context, key, descending));
                }
            }
            else
            {
                throw new Exception("Unsupported!");
            }
        }