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)); }
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; }
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; }
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)); }
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); } } }
internal UnscannedSubExprToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string value, BitArray skippedCharOffsets) : base(scriptExtent, tokenFlags, TokenKind.StringLiteral, value) { this.SkippedCharOffsets = skippedCharOffsets; }
internal FileRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, bool append) : base(scriptExtent, TokenKind.Redirection) { this.FromStream = from; this.Append = append; }
internal Token(InternalScriptExtent scriptExtent, TokenKind kind, System.Management.Automation.Language.TokenFlags tokenFlags) { this._scriptExtent = scriptExtent; this._kind = kind; this._tokenFlags = tokenFlags | kind.GetTraits(); }
internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags tokenFlags) : base(scriptExtent, TokenKind.Number, tokenFlags) { this._value = value; }
internal MergingRedirectionToken(InternalScriptExtent scriptExtent, RedirectionStream from, RedirectionStream to) : base(scriptExtent, TokenKind.Redirection) { this.FromStream = from; this.ToStream = to; }
internal RedirectionToken(InternalScriptExtent scriptExtent, TokenKind kind) : base(scriptExtent, kind, TokenFlags.None) { }
internal ParameterToken(InternalScriptExtent scriptExtent, string parameterName, bool usedColon) : base(scriptExtent, TokenKind.Parameter, TokenFlags.None) { this._parameterName = parameterName; this._usedColon = usedColon; }
internal StringToken(InternalScriptExtent scriptExtent, TokenKind kind, TokenFlags tokenFlags, string value) : base(scriptExtent, kind, tokenFlags) { this._value = value; }
internal StringLiteralToken(InternalScriptExtent scriptExtent, TokenFlags flags, TokenKind tokenKind, string value) : base(scriptExtent, tokenKind, flags, value) { }
internal VariableToken(InternalScriptExtent scriptExtent, System.Management.Automation.VariablePath path, TokenFlags tokenFlags, bool splatted) : base(scriptExtent, splatted ? TokenKind.SplattedVariable : TokenKind.Variable, tokenFlags) { this.VariablePath = path; }
internal Token(InternalScriptExtent scriptExtent, TokenKind kind, TokenFlags tokenFlags) { _scriptExtent = scriptExtent; _kind = kind; _tokenFlags = tokenFlags | kind.GetTraits(); }
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); }
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); }
internal NumberToken(InternalScriptExtent scriptExtent, object value, TokenFlags tokenFlags) : base(scriptExtent, TokenKind.Number, tokenFlags) { _value = value; }
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; }
internal VariableToken(InternalScriptExtent scriptExtent, VariablePath path, TokenFlags tokenFlags, bool splatted) : base(scriptExtent, splatted ? TokenKind.SplattedVariable : TokenKind.Variable, tokenFlags) { VariablePath = path; }
internal LabelToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string labelText) : base(scriptExtent, TokenKind.Label, tokenFlags) { this._labelText = labelText; }
internal LabelToken(InternalScriptExtent scriptExtent, TokenFlags tokenFlags, string labelText) : base(scriptExtent, TokenKind.Label, tokenFlags) { LabelText = labelText; }
internal InputRedirectionToken(InternalScriptExtent scriptExtent) : base(scriptExtent, TokenKind.RedirectInStd) { }