public void testMemberExpression() { String statement = "p.name"; ETestParser parser = new ETestParser(statement, false); IExpression e = parser.parse_instance_expression(); Assert.IsTrue(e is UnresolvedSelector); UnresolvedSelector me = (UnresolvedSelector)e; Assert.AreEqual("name", me.getName()); Assert.IsTrue(me.getParent() is UnresolvedIdentifier); UnresolvedIdentifier uie = (UnresolvedIdentifier)me.getParent(); Assert.AreEqual("p", uie.getName()); }
private IExpression resolveUnresolvedIdentifier(Context context, UnresolvedIdentifier caller) { String name = caller.getName(); // if this happens in the context of a member method, then we need to check for category members first IExpression call = resolveUnresolvedMemberMethod(context, name); if (call == null) { call = resolveUnresolvedMethodReference(context, name); } if (call == null) { call = resolveUnresolvedDeclaration(context, name); } if (call == null) { throw new SyntaxError("Unknown name:" + name); } return(call); }
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!"); } }