public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { // Type expressions are not safe as they allow fingerprinting by providing // a set of types, you can inspect the types in the AppDomain implying which assemblies are in use // and their version return(false); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { // Type expressions are not safe as they allow fingerprinting by providing // a set of types, you can inspect the types in the AppDomain implying which assemblies are in use // and their version throw PSTraceSource.NewArgumentException("ast"); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { // We defer trying to resolve a type expression as an attribute argument // until the script/function is first run, so it's OK if a type expression // as an attribute argument cannot be resolved yet. return(CheckingAttributeArgument || typeExpressionAst.TypeName.GetReflectionType() != null); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { CheckArrayTypeNameDepth(typeExpressionAst.TypeName, typeExpressionAst.Extent, _parser); // If this is access to the [Type] class, it may be suspicious if (typeof(Type) == typeExpressionAst.TypeName.GetReflectionType()) { MarkAstParentsAsSuspicious(typeExpressionAst); } return AstVisitAction.Continue; }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst ast) { return CheckParent(ast); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { DispatchTypeName(typeExpressionAst.TypeName, genericArgumentCount: 0, isAttribute: false); return(AstVisitAction.Continue); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { CheckArrayTypeNameDepth(typeExpressionAst.TypeName, typeExpressionAst.Extent, this._parser); return(AstVisitAction.Continue); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst ast) { return(Check(ast)); }
public System.Object VisitTypeExpression(System.Management.Automation.Language.TypeExpressionAst typeExpressionAst) { IScriptExtent mappedExtent = MapExtent(typeExpressionAst.Extent); return(new TypeExpressionAst(mappedExtent, typeExpressionAst.TypeName)); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { throw new NotImplementedException(typeExpressionAst.ToString()); }
/// <summary> /// Visit type expression /// </summary> /// <param name="typeExpressionAst"></param> /// <returns></returns> public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return null; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return(TypeOps.ResolveTypeName(typeExpressionAst.TypeName)); }
/// <summary/> public virtual AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) => DefaultVisit(typeExpressionAst);
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return TypeOps.ResolveTypeName(typeExpressionAst.TypeName); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return this.CompileTypeName(typeExpressionAst.TypeName); }
private ExpressionAst UnaryExpressionRule() { Token token; ExpressionAst expressionAst; TokenKind tokenKind; Token token1; ExpressionAst convertExpressionAst; RuntimeHelpers.EnsureSufficientExecutionStack(); ExpressionAst typeExpressionAst = null; bool allowSignedNumbers = this._tokenizer.AllowSignedNumbers; try { this._tokenizer.AllowSignedNumbers = true; if (this._ungotToken != null && this._ungotToken.Kind == TokenKind.Minus) { this.Resync(this._ungotToken); } token = this.PeekToken(); } finally { this._tokenizer.AllowSignedNumbers = allowSignedNumbers; } if (!token.Kind.HasTrait(TokenFlags.UnaryOperator)) { if (token.Kind != TokenKind.LBracket) { typeExpressionAst = this.PrimaryExpressionRule(true); } else { List<AttributeBaseAst> attributeBaseAsts = this.AttributeListRule(true); if (attributeBaseAsts != null) { AttributeBaseAst attributeBaseAst = attributeBaseAsts.Last<AttributeBaseAst>(); if (attributeBaseAst as AttributeAst == null) { if (this._ungotToken != null) { token1 = null; } else { token1 = this.NextMemberAccessToken(false); } Token token2 = token1; if (token2 == null) { token = this.PeekToken(); if (token.Kind != TokenKind.NewLine && token.Kind != TokenKind.Comma) { expressionAst = this.UnaryExpressionRule(); if (expressionAst != null) { typeExpressionAst = new ConvertExpressionAst(Parser.ExtentOf(attributeBaseAst, expressionAst), (TypeConstraintAst)attributeBaseAst, expressionAst); } } } else { typeExpressionAst = this.CheckPostPrimaryExpressionOperators(token2, new TypeExpressionAst(attributeBaseAst.Extent, attributeBaseAst.TypeName)); } if (typeExpressionAst == null) { typeExpressionAst = new TypeExpressionAst(attributeBaseAst.Extent, attributeBaseAst.TypeName); } } else { this.SkipNewlines(); expressionAst = this.UnaryExpressionRule(); if (expressionAst != null) { typeExpressionAst = new AttributedExpressionAst(Parser.ExtentOf(attributeBaseAst, expressionAst), attributeBaseAst, expressionAst); } else { object[] fullName = new object[1]; fullName[0] = attributeBaseAst.TypeName.FullName; this.ReportIncompleteInput(attributeBaseAst.Extent, ParserStrings.UnexpectedAttribute, fullName); return new ErrorExpressionAst(Parser.ExtentOf(token, attributeBaseAst), null); } } for (int i = attributeBaseAsts.Count - 2; i >= 0; i--) { TypeConstraintAst item = attributeBaseAsts[i] as TypeConstraintAst; if (item != null) { convertExpressionAst = new ConvertExpressionAst(Parser.ExtentOf(item, typeExpressionAst), item, typeExpressionAst); } else { convertExpressionAst = new AttributedExpressionAst(Parser.ExtentOf(attributeBaseAsts[i], typeExpressionAst), attributeBaseAsts[i], typeExpressionAst); } typeExpressionAst = convertExpressionAst; } } else { return null; } } } else { if (!this._disableCommaOperator || token.Kind != TokenKind.Comma) { this.SkipToken(); this.SkipNewlines(); expressionAst = this.UnaryExpressionRule(); if (expressionAst == null) { object[] text = new object[1]; text[0] = token.Text; this.ReportIncompleteInput(Parser.After(token), ParserStrings.MissingExpressionAfterOperator, text); return new ErrorExpressionAst(token.Extent, null); } else { if (token.Kind != TokenKind.Comma) { typeExpressionAst = new UnaryExpressionAst(Parser.ExtentOf(token, expressionAst), token.Kind, expressionAst); } else { ExpressionAst[] expressionAstArray = new ExpressionAst[1]; expressionAstArray[0] = expressionAst; typeExpressionAst = new ArrayLiteralAst(Parser.ExtentOf(token, expressionAst), expressionAstArray); } } } else { return null; } } if (typeExpressionAst != null) { token = this.PeekToken(); if (token.Kind == TokenKind.PlusPlus) { tokenKind = TokenKind.PostfixPlusPlus; } else { if (token.Kind == TokenKind.MinusMinus) { tokenKind = TokenKind.PostfixMinusMinus; } else { tokenKind = TokenKind.Unknown; } } TokenKind tokenKind1 = tokenKind; if (tokenKind1 != TokenKind.Unknown) { this.SkipToken(); typeExpressionAst = new UnaryExpressionAst(Parser.ExtentOf(typeExpressionAst, token), tokenKind1, typeExpressionAst); } } return typeExpressionAst; }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { CheckArrayTypeNameDepth(typeExpressionAst.TypeName, typeExpressionAst.Extent, this._parser); return AstVisitAction.Continue; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return(this.CheckingAttributeArgument ? ((object)true) : ((object)(typeExpressionAst.TypeName.GetReflectionType() != null))); }
private ExpressionAst UnaryExpressionRule() { //G unary-expression: //G primary-expression //G expression-with-unary-operator //G //G expression-with-unary-operator: //G ',' new-lines:opt unary-expression //G '-not' new-lines:opt unary-expression //G '!' new-lines:opt unary-expression //G '-bnot' new-lines:opt unary-expression //G '+' new-lines:opt unary-expression //G dash new-lines:opt unary-expression //G pre-increment-expression //G pre-decrement-expression //G cast-expression //G '-split' new-lines:opt unary-expression //G '-join' new-lines:opt unary-expression //G //G pre-increment-expression: //G '++' new-lines:opt unary-expression //G //G pre-decrement-expression: //G dashdash new-lines:opt unary-expression //G //G cast-expression: //G type-literal unary-expression RuntimeHelpers.EnsureSufficientExecutionStack(); ExpressionAst expr = null; Token token; bool oldAllowSignedNumbers = _tokenizer.AllowSignedNumbers; try { _tokenizer.AllowSignedNumbers = true; if (_ungotToken != null && _ungotToken.Kind == TokenKind.Minus) { Resync(_ungotToken); } token = PeekToken(); } finally { _tokenizer.AllowSignedNumbers = oldAllowSignedNumbers; } ExpressionAst child; if (token.Kind.HasTrait(TokenFlags.UnaryOperator)) { if (_disableCommaOperator && token.Kind == TokenKind.Comma) { return null; } SkipToken(); SkipNewlines(); child = UnaryExpressionRule(); if (child != null) { if (token.Kind == TokenKind.Comma) { expr = new ArrayLiteralAst(ExtentOf(token, child), new ExpressionAst[] { child }); } else { expr = new UnaryExpressionAst(ExtentOf(token, child), token.Kind, child); } } else { // ErrorRecovery: don't bother constructing a unary expression, but we know we must have // some sort of expression, so return an error expression. // Use token.Text, not token.Kind.Text() b/c the kind might not match the actual operator used // when a case insensitive operator is used. ReportIncompleteInput(After(token), () => ParserStrings.MissingExpressionAfterOperator, token.Text); return new ErrorExpressionAst(token.Extent); } } else if (token.Kind == TokenKind.LBracket) { // Possibly a type literal or attribute. var attributes = AttributeListRule(true); if (attributes == null) { return null; } AttributeBaseAst lastAttribute = attributes.Last(); if (lastAttribute is AttributeAst) { SkipNewlines(); child = UnaryExpressionRule(); if (child == null) { // ErrorRecovery: We have a list of attributes, and we know it's not before a param statement, // so we know we must have some sort of expression. Return an error expression then. ReportIncompleteInput(lastAttribute.Extent, () => ParserStrings.UnexpectedAttribute, lastAttribute.TypeName.FullName); return new ErrorExpressionAst(ExtentOf(token, lastAttribute)); } expr = new AttributedExpressionAst(ExtentOf(lastAttribute, child), lastAttribute, child); } else { Diagnostics.Assert(_ungotToken == null || ErrorList.Count > 0, "Unexpected lookahead from AttributeListRule."); // If we've looked ahead, don't go looking for a member access token, we've already issued an error, // just assume we're not trying to access a member. var memberAccessToken = _ungotToken != null ? null : NextMemberAccessToken(false); if (memberAccessToken != null) { expr = CheckPostPrimaryExpressionOperators(memberAccessToken, new TypeExpressionAst(lastAttribute.Extent, lastAttribute.TypeName)); } else { token = PeekToken(); if (token.Kind != TokenKind.NewLine && token.Kind != TokenKind.Comma) { child = UnaryExpressionRule(); if (child != null) { expr = new ConvertExpressionAst(ExtentOf(lastAttribute, child), (TypeConstraintAst)lastAttribute, child); } } } if (expr == null) { expr = new TypeExpressionAst(lastAttribute.Extent, lastAttribute.TypeName); } } for (int i = attributes.Count - 2; i >= 0; --i) { var typeConstraint = attributes[i] as TypeConstraintAst; expr = typeConstraint != null ? new ConvertExpressionAst(ExtentOf(typeConstraint, expr), typeConstraint, expr) : new AttributedExpressionAst(ExtentOf(attributes[i], expr), attributes[i], expr); } } else { expr = PrimaryExpressionRule(withMemberAccess: true); } if (expr != null) { token = PeekToken(); TokenKind operation = (token.Kind == TokenKind.PlusPlus) ? TokenKind.PostfixPlusPlus : (token.Kind == TokenKind.MinusMinus) ? TokenKind.PostfixMinusMinus : TokenKind.Unknown; if (operation != TokenKind.Unknown) { SkipToken(); expr = new UnaryExpressionAst(ExtentOf(expr, token), operation, expr); } } return expr; }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { this.CheckTypeName(typeExpressionAst, typeExpressionAst.TypeName); return AstVisitAction.Continue; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { throw new UnexpectedElementException(); }
/// <summary/> public virtual object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return _decorated.VisitTypeExpression(typeExpressionAst); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { this.CheckTypeName(typeExpressionAst, typeExpressionAst.TypeName); return(AstVisitAction.Continue); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { DispatchTypeName(typeExpressionAst.TypeName, genericArgumentCount: 0, isAttribute: false); return AstVisitAction.Continue; }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst ast) { return this.Check(ast); }
public override AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { this._pipelineCommandRuntime.outputResults.Write(typeExpressionAst.TypeName.GetReflectionType()); return AstVisitAction.SkipChildren; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return true; }
public virtual AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return AstVisitAction.Continue; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { // We defer trying to resolve a type expression as an attribute argument // until the script/function is first run, so it's OK if a type expression // as an attribute argument cannot be resolved yet. return CheckingAttributeArgument || typeExpressionAst.TypeName.GetReflectionType() != null; }
/// <summary/> public virtual object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return(null); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { CheckIsConstant(typeExpressionAst, "Caller to verify ast is constant"); return typeExpressionAst.TypeName.GetReflectionType(); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return (this.CheckingAttributeArgument ? ((object) true) : ((object) (typeExpressionAst.TypeName.GetReflectionType() != null))); }
internal override IEnumerable <PSTypeName> GetInferredType(CompletionContext context) { StringConstantExpressionAst member = this.Member as StringConstantExpressionAst; if (member != null) { PSTypeName[] iteratorVariable1; if (this.Static) { TypeExpressionAst expression = this.Expression as TypeExpressionAst; if (expression == null) { goto Label_064A; } Type type = expression.TypeName.GetReflectionType(); if (type == null) { goto Label_064A; } iteratorVariable1 = new PSTypeName[] { new PSTypeName(type) }; } else { iteratorVariable1 = this.Expression.GetInferredType(context).ToArray <PSTypeName>(); if (iteratorVariable1.Length == 0) { goto Label_064A; } } List <string> iteratorVariable2 = new List <string> { member.Value }; foreach (PSTypeName iteratorVariable3 in iteratorVariable1) { IEnumerable <object> iteratorVariable4 = CompletionCompleters.GetMembersByInferredType(iteratorVariable3, this.Static, context); for (int i = 0; i < iteratorVariable2.Count; i++) { string iteratorVariable6 = iteratorVariable2[i]; foreach (object iteratorVariable7 in iteratorVariable4) { PropertyInfo iteratorVariable8 = iteratorVariable7 as PropertyInfo; if (iteratorVariable8 != null) { if (iteratorVariable8.Name.Equals(iteratorVariable6, StringComparison.OrdinalIgnoreCase) && !(this is InvokeMemberExpressionAst)) { yield return(new PSTypeName(iteratorVariable8.PropertyType)); break; } } else { FieldInfo iteratorVariable9 = iteratorVariable7 as FieldInfo; if (iteratorVariable9 != null) { if (iteratorVariable9.Name.Equals(iteratorVariable6, StringComparison.OrdinalIgnoreCase) && !(this is InvokeMemberExpressionAst)) { yield return(new PSTypeName(iteratorVariable9.FieldType)); break; } continue; } DotNetAdapter.MethodCacheEntry iteratorVariable10 = iteratorVariable7 as DotNetAdapter.MethodCacheEntry; if (iteratorVariable10 != null) { if (iteratorVariable10[0].method.Name.Equals(iteratorVariable6, StringComparison.OrdinalIgnoreCase)) { if (!(this is InvokeMemberExpressionAst)) { yield return(new PSTypeName(typeof(PSMethod))); break; } foreach (MethodInformation iteratorVariable11 in iteratorVariable10.methodInformationStructures) { MethodInfo method = iteratorVariable11.method as MethodInfo; if ((method != null) && !method.ReturnType.ContainsGenericParameters) { yield return(new PSTypeName(method.ReturnType)); } } break; } continue; } PSMemberInfo iteratorVariable13 = iteratorVariable7 as PSMemberInfo; if ((iteratorVariable13 != null) && iteratorVariable13.Name.Equals(iteratorVariable6, StringComparison.OrdinalIgnoreCase)) { PSNoteProperty iteratorVariable14 = iteratorVariable7 as PSNoteProperty; if (iteratorVariable14 != null) { yield return(new PSTypeName(iteratorVariable14.Value.GetType())); break; } PSAliasProperty iteratorVariable15 = iteratorVariable7 as PSAliasProperty; if (iteratorVariable15 != null) { iteratorVariable2.Add(iteratorVariable15.ReferencedMemberName); } else { PSCodeProperty iteratorVariable16 = iteratorVariable7 as PSCodeProperty; if (iteratorVariable16 != null) { if (iteratorVariable16.GetterCodeReference != null) { yield return(new PSTypeName(iteratorVariable16.GetterCodeReference.ReturnType)); break; } } else { ScriptBlock getterScript = null; PSScriptProperty iteratorVariable18 = iteratorVariable7 as PSScriptProperty; if (iteratorVariable18 != null) { getterScript = iteratorVariable18.GetterScript; } PSScriptMethod iteratorVariable19 = iteratorVariable7 as PSScriptMethod; if (iteratorVariable19 != null) { getterScript = iteratorVariable19.Script; } if (getterScript != null) { foreach (PSTypeName iteratorVariable20 in getterScript.OutputType) { yield return(iteratorVariable20); } } } } break; } } } } } } Label_064A: yield break; }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { // Type expressions are not safe as they allow fingerprinting by providing // a set of types, you can inspect the types in the AppDomain implying which assemblies are in use // and their version return false; }
/// <summary/> public virtual AstVisitAction VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return(AstVisitAction.Continue); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { return CompileTypeName(typeExpressionAst.TypeName, typeExpressionAst.Extent); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { CheckIsConstant(typeExpressionAst, "Caller to verify ast is constant"); return(typeExpressionAst.TypeName.GetReflectionType()); }
public object VisitTypeExpression(TypeExpressionAst typeExpressionAst) { throw new NotImplementedException(); }