public virtual void Visit(TypeOfDeclaration td)
        {
            VisitInner(td);

            if (td.Expression != null)
            {
                td.Expression.Accept(this);
            }
        }
        public virtual void Visit(TypeOfDeclaration td)
        {
            VisitInner(td);

            if (td.InstanceId != null)
            {
                td.InstanceId.Accept(this);
            }
        }
        bool HandleDecl(TypeOfDeclaration t, AbstractType r)
        {
            // Can I enter some template parameter referencing id into a typeof specialization!?
            // class Foo(T:typeof(1)) {} ?
            var t_res = TypeDeclarationResolver.Resolve(t,ctxt);

            if (t_res == null)
                return false;

            return ResultComparer.IsImplicitlyConvertible(r,t_res);
        }
Example #4
0
        TypeOfDeclaration TypeOf()
        {
            Expect(Typeof);
            var md = new TypeOfDeclaration { Location = t.Location };

            if (Expect(OpenParenthesis))
            {
                if (laKind == Return)
                {
                    Step();
                    md.Expression = new TokenExpression(Return) { Location = t.Location, EndLocation = t.EndLocation };
                }
                else
                    md.Expression = Expression();
                Expect(CloseParenthesis);
            }
            md.EndLocation = t.EndLocation;
            return md;
        }
        public virtual void Visit(TypeOfDeclaration td)
        {
            VisitInner(td);

            if (td.Expression != null)
                td.Expression.Accept(this);
        }
Example #6
0
 TypeOfDeclaration TypeOf()
 {
     var startLoc = t==null?new CodeLocation():t.Location;
     Expect(Typeof);
     Expect(OpenParenthesis);
     var md = new TypeOfDeclaration { Location=startLoc };
     LastParsedObject = md;
     if (laKind == (Return))
     {
         Step();
         md.InstanceId = new TokenExpression(Return) { Location = t.Location, EndLocation = t.EndLocation };
     }
     else
         md.InstanceId = Expression();
     Expect(CloseParenthesis);
     md.EndLocation = t.EndLocation;
     return md;
 }
        public static AbstractType Resolve(TypeOfDeclaration typeOf, ResolutionContext ctxt)
        {
            // typeof(return)
            if (typeOf.Expression is TokenExpression && (typeOf.Expression as TokenExpression).Token == DTokens.Return)
            {
                var m = HandleNodeMatch(ctxt.ScopedBlock, ctxt, null, typeOf);
                if (m != null)
                    return m;
            }
            // typeOf(myInt)  =>  int
            else if (typeOf.Expression != null)
            {
                var wantedTypes = Evaluation.EvaluateType(typeOf.Expression, ctxt);
                return DResolver.StripMemberSymbols(wantedTypes);
            }

            return null;
        }