Exemplo n.º 1
0
        internal static MemberAccessExpr Bound(Binder b, Expr expr, Expr member, BindAffinity affinity)
        {
            expr.RequireValue();
            var e = new MemberAccessExpr(expr, Token.None, member);

            e.Symbol   = b.BindMemberAccess(ref e.Expr, ref e.Member, affinity);
            e.Datatype = e.Symbol.Type();
            return(e);
        }
Exemplo n.º 2
0
        internal static MethodCallExpr Bound(Binder b, Expr e, Symbol sym, Expr self, ArgList args)
        {
            Expr boundSelf;
            Expr writeBack;

            if (self != null)
            {
                e = new MemberAccessExpr(self, null, null);
            }
            var m = b.BindMethodCall(e, sym, args, out boundSelf, out writeBack);

            return(new MethodCallExpr(e, args)
            {
                Symbol = m, Datatype = m.Type(), Self = boundSelf, WriteBack = writeBack
            });
        }
Exemplo n.º 3
0
        internal static MethodCallExpr Bound(Binder b, Expr e, string name, ArgList args)
        {
            Expr m = new IdExpr(name);
            Expr self;
            Expr writeBack;
            var  ms = b.BindMemberAccess(ref e, ref m, BindAffinity.Invoke);

            if (!(ms is MethodSymbol))
            {
                throw e.Error(ErrorCode.Internal);
            }
            var expr = new MemberAccessExpr(e, e.Token, m)
            {
                Symbol = ms
            };
            var sym = b.BindMethodCall(expr, ms, ArgList.Empty, out self, out writeBack);

            return(Bound(e, sym, self, ArgList.Empty, writeBack));
        }
Exemplo n.º 4
0
        internal override Node Bind(Binder b)
        {
            b.Bind(ref Expr, BindAffinity.Type);
            var s = Expr.Symbol.UniqueTypeOrNamespace();

            if (s is TypeSymbol t)
            {
                Expr.Symbol = t;
                Symbol      = b.Lookup(t, Member.LookupName) ?? ThrowError(Binder.LookupError(Expr, this));
                Datatype    = Symbol.Type();
            }
            else if (s is NamespaceSymbol ns)
            {
                Expr.Symbol = ns;
                Symbol      = b.Lookup(ns, Member.LookupName) ?? ThrowError(Binder.LookupError(Expr, this));
                Datatype    = Symbol.Type();
            }
            if (Symbol == null)
            {
                if (b.Options.AllowDotAccess)
                {
                    if (b.Options.UndeclaredVariableResolution != VariableResolution.TreatAsField)
                    {
                        Expr.Symbol = null; // re-bind Expr -- this is a hack!!!
                        b.Bind(ref Expr, Affinity);
                    }
                    if (Expr.Symbol.UniqueIdent() != null)
                    {
                        return(MemberAccessExpr.Bound(b, Expr, Member, Affinity));
                    }
                    if (Expr is NameExpr aname && Member is NameExpr fname)
                    {
                        return(AliasExpr.Bound(aname.LookupName, fname.LookupName));
                    }
                    Expr.RequireValue();
                }
                else
                {
                    Expr.RequireType();
                }
            }
            return(null);
        }