Пример #1
0
        internal static IScriptExtent NewScriptExtent(IScriptExtent start, IScriptExtent end)
        {
            if (start == end)
            {
                return(start);
            }

            if (start == EmptyExtent)
            {
                return(end);
            }

            if (end == EmptyExtent)
            {
                return(start);
            }

            InternalScriptExtent startExtent = start as InternalScriptExtent;
            InternalScriptExtent endExtent   = end as InternalScriptExtent;

            Diagnostics.Assert(startExtent != null && endExtent != null, "This function only handles internal and empty extents");
            Diagnostics.Assert(startExtent.PositionHelper == endExtent.PositionHelper, "Extents must be from same source");

            return(new InternalScriptExtent(startExtent.PositionHelper, startExtent.StartOffset, endExtent.EndOffset));
        }
Пример #2
0
 internal StringExpandableToken(InternalScriptExtent scriptExtent, TokenKind tokenKind, string value, string formatString, List<Token> nestedTokens, TokenFlags flags) : base(scriptExtent, tokenKind, flags, value)
 {
     if ((nestedTokens != null) && nestedTokens.Any<Token>())
     {
         this._nestedTokens = new ReadOnlyCollection<Token>(nestedTokens.ToArray());
     }
     this._formatString = formatString;
 }
Пример #3
0
 internal StringExpandableToken(InternalScriptExtent scriptExtent, TokenKind tokenKind, string value, string formatString, List <Token> nestedTokens, TokenFlags flags) : base(scriptExtent, tokenKind, flags, value)
 {
     if ((nestedTokens != null) && nestedTokens.Any <Token>())
     {
         this._nestedTokens = new ReadOnlyCollection <Token>(nestedTokens.ToArray());
     }
     this._formatString = formatString;
 }
Пример #4
0
        internal static IScriptExtent NewScriptExtent(IScriptExtent start, IScriptExtent end)
        {
            if (start == end)
            {
                return(start);
            }
            if (start == emptyExtent)
            {
                return(end);
            }
            if (end == emptyExtent)
            {
                return(start);
            }
            InternalScriptExtent extent  = start as InternalScriptExtent;
            InternalScriptExtent extent2 = end as InternalScriptExtent;

            return(new InternalScriptExtent(extent.PositionHelper, extent.StartOffset, extent2.EndOffset));
        }
Пример #5
0
        public NamedBlockAst(IScriptExtent extent, TokenKind blockName, StatementBlockAst statementBlock, bool unnamed) : base(extent)
        {
            if (!blockName.HasTrait(TokenFlags.ScriptBlockBlockName) || (unnamed && ((blockName == TokenKind.Begin) || (blockName == TokenKind.Dynamicparam))))
            {
                throw PSTraceSource.NewArgumentException("blockName");
            }
            if (statementBlock == null)
            {
                throw PSTraceSource.NewArgumentNullException("statementBlock");
            }
            this.Unnamed   = unnamed;
            this.BlockKind = blockName;
            ReadOnlyCollection <StatementAst> statements = statementBlock.Statements;

            this.Statements = statements;
            foreach (StatementAst ast in statements)
            {
                ast.ClearParent();
            }
            base.SetParents((IEnumerable <Ast>)statements);
            ReadOnlyCollection <TrapStatementAst> traps = statementBlock.Traps;

            if ((traps != null) && traps.Any <TrapStatementAst>())
            {
                this.Traps = traps;
                foreach (TrapStatementAst ast2 in traps)
                {
                    ast2.ClearParent();
                }
                base.SetParents((IEnumerable <Ast>)traps);
            }
            if (!unnamed)
            {
                InternalScriptExtent extent2 = statementBlock.Extent as InternalScriptExtent;
                if (extent2 != null)
                {
                    this.OpenCurlyExtent  = new InternalScriptExtent(extent2.PositionHelper, extent2.StartOffset, extent2.StartOffset + 1);
                    this.CloseCurlyExtent = new InternalScriptExtent(extent2.PositionHelper, extent2.EndOffset - 1, extent2.EndOffset);
                }
            }
        }
Пример #6
0
 internal UnscannedSubExprToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string value, BitArray skippedCharOffsets)
     : base(scriptExtent, tokenFlags, TokenKind.StringLiteral, value)
 {
     this.SkippedCharOffsets = skippedCharOffsets;
 }
Пример #7
0
 internal FileRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, bool append)
     : base(scriptExtent, TokenKind.Redirection)
 {
     this.FromStream = from;
     this.Append = append;
 }
Пример #8
0
 internal Token(InternalScriptExtent scriptExtent, TokenKind kind, System.Management.Automation.Language.TokenFlags tokenFlags)
 {
     this._scriptExtent = scriptExtent;
     this._kind         = kind;
     this._tokenFlags   = tokenFlags | kind.GetTraits();
 }
Пример #9
0
 internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags tokenFlags) : base(scriptExtent, TokenKind.Number, tokenFlags)
 {
     this._value = value;
 }
Пример #10
0
 internal MergingRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, RedirectionStream to) : base(scriptExtent, TokenKind.Redirection)
 {
     this.FromStream = from;
     this.ToStream   = to;
 }
Пример #11
0
 internal UnscannedSubExprToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string value, BitArray skippedCharOffsets) : base(scriptExtent, tokenFlags, TokenKind.StringLiteral, value)
 {
     this.SkippedCharOffsets = skippedCharOffsets;
 }
Пример #12
0
 internal RedirectionToken(InternalScriptExtent scriptExtent, TokenKind kind) : base(scriptExtent, kind, TokenFlags.None)
 {
 }
Пример #13
0
 internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName, bool usedColon) : base(scriptExtent, TokenKind.Parameter, TokenFlags.None)
 {
     this._parameterName = parameterName;
     this._usedColon = usedColon;
 }
Пример #14
0
 internal StringToken(InternalScriptExtent scriptExtent, TokenKind kind, TokenFlags tokenFlags, string value) : base(scriptExtent, kind, tokenFlags)
 {
     this._value = value;
 }
Пример #15
0
 internal StringLiteralToken(InternalScriptExtent scriptExtent, TokenFlags flags, TokenKind tokenKind, string value) : base(scriptExtent, tokenKind, flags, value)
 {
 }
Пример #16
0
 internal Token(InternalScriptExtent scriptExtent, TokenKind kind, System.Management.Automation.Language.TokenFlags tokenFlags)
 {
     this._scriptExtent = scriptExtent;
     this._kind = kind;
     this._tokenFlags = tokenFlags | kind.GetTraits();
 }
Пример #17
0
 internal FileRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, bool append) : base(scriptExtent, TokenKind.Redirection)
 {
     this.FromStream = from;
     this.Append     = append;
 }
Пример #18
0
 internal VariableToken(InternalScriptExtent scriptExtent, System.Management.Automation.VariablePath path, TokenFlags tokenFlags, bool splatted) : base(scriptExtent, splatted ? TokenKind.SplattedVariable : TokenKind.Variable, tokenFlags)
 {
     this.VariablePath = path;
 }
Пример #19
0
 internal StringLiteralToken(InternalScriptExtent scriptExtent, TokenFlags flags, TokenKind tokenKind, string value) : base(scriptExtent, tokenKind, flags, value)
 {
 }
Пример #20
0
 internal RedirectionToken(InternalScriptExtent scriptExtent, TokenKind kind) : base(scriptExtent, kind, TokenFlags.None)
 {
 }
Пример #21
0
 internal Token(InternalScriptExtent scriptExtent, TokenKind kind, TokenFlags tokenFlags)
 {
     _scriptExtent = scriptExtent;
     _kind = kind;
     _tokenFlags = tokenFlags | kind.GetTraits();
 }
Пример #22
0
 private Expression<Action<FunctionContext>> CompileNamedBlock(NamedBlockAst namedBlockAst, string funcName)
 {
     IScriptExtent entryExtent = null;
     IScriptExtent exitExtent = null;
     if (namedBlockAst.Unnamed)
     {
         ScriptBlockAst parent = (ScriptBlockAst) namedBlockAst.Parent;
         if ((parent.Parent != null) && (parent.Extent is InternalScriptExtent))
         {
             InternalScriptExtent extent = (InternalScriptExtent) parent.Extent;
             entryExtent = new InternalScriptExtent(extent.PositionHelper, extent.StartOffset, extent.StartOffset + 1);
             exitExtent = new InternalScriptExtent(extent.PositionHelper, extent.EndOffset - 1, extent.EndOffset);
         }
     }
     else
     {
         entryExtent = namedBlockAst.OpenCurlyExtent;
         exitExtent = namedBlockAst.CloseCurlyExtent;
     }
     return this.CompileSingleLambda(namedBlockAst.Statements, namedBlockAst.Traps, funcName, entryExtent, exitExtent);
 }
Пример #23
0
        private Expression<Action<FunctionContext>> CompileNamedBlock(NamedBlockAst namedBlockAst, string funcName, ScriptBlockAst rootForDefiningTypes)
        {
            IScriptExtent entryExtent = null;
            IScriptExtent exitExtent = null;
            if (namedBlockAst.Unnamed)
            {
                // Get extent from the function or scriptblock expression parent, if any.
                var scriptBlock = (ScriptBlockAst)namedBlockAst.Parent;
                if (scriptBlock.Parent != null && scriptBlock.Extent is InternalScriptExtent)
                {
                    // We must have curlies at the start/end.
                    var scriptExtent = (InternalScriptExtent)scriptBlock.Extent;
                    entryExtent = new InternalScriptExtent(scriptExtent.PositionHelper, scriptExtent.StartOffset, scriptExtent.StartOffset + 1);
                    exitExtent = new InternalScriptExtent(scriptExtent.PositionHelper, scriptExtent.EndOffset - 1, scriptExtent.EndOffset);
                }
            }
            else
            {
                entryExtent = namedBlockAst.OpenCurlyExtent;
                exitExtent = namedBlockAst.CloseCurlyExtent;
            }

            return CompileSingleLambda(namedBlockAst.Statements, namedBlockAst.Traps, funcName, entryExtent, exitExtent, rootForDefiningTypes);
        }
Пример #24
0
 internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags tokenFlags)
     : base(scriptExtent, TokenKind.Number, tokenFlags)
 {
     _value = value;
 }
Пример #25
0
 internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName, bool usedColon)
     : base(scriptExtent, TokenKind.Parameter, TokenFlags.None)
 {
     Diagnostics.Assert(!string.IsNullOrEmpty(parameterName), "parameterName can't be null or empty");
     _parameterName = parameterName;
     _usedColon = usedColon;
 }
Пример #26
0
 internal VariableToken(InternalScriptExtent scriptExtent, VariablePath path, TokenFlags tokenFlags, bool splatted)
     : base(scriptExtent, splatted ? TokenKind.SplattedVariable : TokenKind.Variable, tokenFlags)
 {
     VariablePath = path;
 }
Пример #27
0
 internal LabelToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string labelText) : base(scriptExtent, TokenKind.Label, tokenFlags)
 {
     this._labelText = labelText;
 }
Пример #28
0
 internal LabelToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string labelText)
     : base(scriptExtent, TokenKind.Label, tokenFlags)
 {
     LabelText = labelText;
 }
Пример #29
0
 internal InputRedirectionToken(InternalScriptExtent scriptExtent) : base(scriptExtent, TokenKind.RedirectInStd)
 {
 }
Пример #30
0
 internal InputRedirectionToken(InternalScriptExtent scriptExtent)
     : base(scriptExtent, TokenKind.RedirectInStd)
 {
 }
Пример #31
0
 internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName, bool usedColon) : base(scriptExtent, TokenKind.Parameter, TokenFlags.None)
 {
     this._parameterName = parameterName;
     this._usedColon     = usedColon;
 }
Пример #32
0
 internal MergingRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, RedirectionStream to)
     : base(scriptExtent, TokenKind.Redirection)
 {
     this.FromStream = from;
     this.ToStream = to;
 }
Пример #33
0
 internal StringToken(InternalScriptExtent scriptExtent, TokenKind kind, TokenFlags tokenFlags, string value) : base(scriptExtent, kind, tokenFlags)
 {
     this._value = value;
 }
Пример #34
0
 internal VariableToken(InternalScriptExtent scriptExtent, System.Management.Automation.VariablePath path, TokenFlags tokenFlags, bool splatted) : base(scriptExtent, splatted ? TokenKind.SplattedVariable : TokenKind.Variable, tokenFlags)
 {
     this.VariablePath = path;
 }