Exemplo n.º 1
0
        BoundExpression BindPseudoConst(AST.PseudoConstUse x)
        {
            var unit = _routine.ContainingFile.Syntax.SourceUnit;

            switch (x.Type)
            {
            case AST.PseudoConstUse.Types.Line:
                return(new BoundLiteral(unit.LineBreaks.GetLineFromPosition(x.Span.Start) + 1));

            case AST.PseudoConstUse.Types.Dir:
            case AST.PseudoConstUse.Types.File:
                return(new BoundPseudoConst(x.Type));

            case AST.PseudoConstUse.Types.Function:
                if (_routine is SourceFunctionSymbol || _routine is SourceMethodSymbol)
                {
                    return(new BoundLiteral(_routine.Name));
                }
                if (_routine is SourceGlobalMethodSymbol)
                {
                    return(new BoundLiteral(string.Empty));
                }

                throw ExceptionUtilities.UnexpectedValue(_routine);

            case AST.PseudoConstUse.Types.Method:
                if (_routine is SourceMethodSymbol)
                {
                    return(new BoundLiteral(_routine.ContainingType.MakeQualifiedName().ToString(new Name(_routine.Name), false)));
                }

                goto case AST.PseudoConstUse.Types.Function;

            case AST.PseudoConstUse.Types.Class:
                if (_flowCtx.TypeRefContext.ContainingType != null)
                {
                    return(new BoundLiteral(_flowCtx.TypeRefContext.ContainingType.MakeQualifiedName().ToString()));
                }

                return(new BoundLiteral(string.Empty));

            default:
                throw new NotImplementedException(x.Type.ToString());        //
            }
        }