Example #1
0
        BoundExpression BindConstUse(AST.ConstantUse x)
        {
            if (x is AST.GlobalConstUse)
            {
                return(BindGlobalConstUse((AST.GlobalConstUse)x));
            }

            if (x is AST.ClassConstUse)
            {
                var cx      = (AST.ClassConstUse)x;
                var typeref = BindTypeRef(cx.TargetType);

                if (cx.Name.Equals("class"))   // pseudo class constant
                {
                    return(new BoundPseudoClassConst(typeref, AST.PseudoClassConstUse.Types.Class));
                }

                return(BoundFieldRef.CreateClassConst(typeref, new BoundVariableName(cx.Name)));
            }

            throw ExceptionUtilities.UnexpectedValue(x);
        }
Example #2
0
        BoundExpression BindConstUse(AST.ConstantUse x)
        {
            if (x is AST.GlobalConstUse)
            {
                return(BindGlobalConstUse((AST.GlobalConstUse)x));
            }

            if (x is AST.ClassConstUse)
            {
                var cx    = (AST.ClassConstUse)x;
                var dtype = cx.TypeRef as AST.DirectTypeRef;
                if (dtype != null && cx.Name.Equals("class"))   // Type::class ~ "Type"
                {
                    return(new BoundLiteral(dtype.ClassName.ToString()));
                }

                var typeref = BindTypeRef(cx.TypeRef);

                return(BoundFieldRef.CreateClassConst(typeref, new BoundVariableName(cx.Name)));
            }

            throw ExceptionUtilities.UnexpectedValue(x);
        }