コード例 #1
0
        internal override IEnumerable <PSTypeName> GetInferredType(CompletionContext context)
        {
            TypeConstraintAst iteratorVariable0 = this.Attributes.OfType <TypeConstraintAst>().FirstOrDefault <TypeConstraintAst>();

            if (iteratorVariable0 != null)
            {
                Type reflectionType = iteratorVariable0.TypeName.GetReflectionType();
                if (reflectionType != null)
                {
                    yield return(new PSTypeName(reflectionType));
                }
                else
                {
                    yield return(new PSTypeName(iteratorVariable0.TypeName.FullName));
                }
            }
            IEnumerator <AttributeAst> enumerator = this.Attributes.OfType <AttributeAst>().GetEnumerator();

            while (enumerator.MoveNext())
            {
                AttributeAst        current   = enumerator.Current;
                PSTypeNameAttribute attribute = null;
                try
                {
                    attribute = current.GetAttribute() as PSTypeNameAttribute;
                }
                catch (RuntimeException)
                {
                }
                if (attribute != null)
                {
                    yield return(new PSTypeName(attribute.PSTypeName));
                }
            }
        }
コード例 #2
0
 private void CheckForDuplicateParameters(IEnumerable <ParameterAst> parameters)
 {
     if (parameters.Any <ParameterAst>())
     {
         HashSet <string> set = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
         foreach (ParameterAst ast in parameters)
         {
             string userPath = ast.Name.VariablePath.UserPath;
             if (set.Contains(userPath))
             {
                 this._parser.ReportError(ast.Name.Extent, ParserStrings.DuplicateFormalParameter, new object[] { userPath });
             }
             else
             {
                 set.Add(userPath);
             }
             TypeConstraintAst ast2 = (from t in ast.Attributes.OfType <TypeConstraintAst>()
                                       where typeof(void).Equals(t.TypeName.GetReflectionType())
                                       select t).FirstOrDefault <TypeConstraintAst>();
             if (ast2 != null)
             {
                 this._parser.ReportError(ast2.Extent, ParserStrings.VoidTypeConstraintNotAllowed, new object[0]);
             }
         }
     }
 }
コード例 #3
0
        public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast)
        {
            Type type = ast.TypeName.GetReflectionType();

            if (type != null)
            {
                Diagnostics.Assert(!(type is TypeBuilder), "ReflectionType can never be TypeBuilder");
            }
            return(AstVisitAction.Continue);
        }
コード例 #4
0
ファイル: TrapStatementAst.cs プロジェクト: nickchal/pash
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (trapType != null)
     {
         this.TrapType = trapType;
         base.SetParent(trapType);
     }
     this.Body = body;
     base.SetParent(body);
 }
コード例 #5
0
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (trapType != null)
     {
         this.TrapType = trapType;
         base.SetParent(trapType);
     }
     this.Body = body;
     base.SetParent(body);
 }
コード例 #6
0
ファイル: Compiler.cs プロジェクト: nickchal/pash
 internal static Attribute GetAttribute(TypeConstraintAst typeConstraintAst)
 {
     Type type = TypeOps.ResolveTypeName(typeConstraintAst.TypeName);
     return new ArgumentTypeConverterAttribute(new Type[] { type });
 }
コード例 #7
0
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     CheckArrayTypeNameDepth(typeConstraintAst.TypeName, typeConstraintAst.Extent, this._parser);
     return(AstVisitAction.Continue);
 }
コード例 #8
0
ファイル: ExecutionVisitor.cs プロジェクト: stangelandcl/Pash
 private bool IsExactMatch(TypeConstraintAst typeConstraintAst, Exception ex)
 {
     return (typeConstraintAst != null) && (ex.GetType() == typeConstraintAst.TypeName.GetReflectionType());
 }
コード例 #9
0
ファイル: ExecutionVisitor.cs プロジェクト: JayBazuzi/Pash
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     throw new NotImplementedException(); //VisitTypeConstraint(typeConstraintAst);
 }
コード例 #10
0
 /// <summary>
 /// Visit type constraint
 /// </summary>
 /// <param name="typeConstraintAst"></param>
 /// <returns></returns>
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     System.Diagnostics.Debug.Assert(false, "Code is unreachable");
     return null;
 }
コード例 #11
0
ファイル: SymbolResolver.cs プロジェクト: 40a/PowerShell
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     DispatchTypeName(typeConstraintAst.TypeName, genericArgumentCount: 0, isAttribute: false);
     return AstVisitAction.Continue;
 }
コード例 #12
0
ファイル: ConstantValues.cs プロジェクト: 40a/PowerShell
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return AutomationNull.Value; }
コード例 #13
0
 public ConvertExpressionAst(IScriptExtent extent, TypeConstraintAst typeConstraint, ExpressionAst child)
     : base(extent, typeConstraint, child)
 {
     this.Type = typeConstraint;
 }
コード例 #14
0
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     this.CheckTypeName(typeConstraintAst, typeConstraintAst.TypeName);
     return(AstVisitAction.Continue);
 }
コード例 #15
0
ファイル: AstSearcher.cs プロジェクト: nickchal/pash
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast)
 {
     return this.Check(ast);
 }
コード例 #16
0
ファイル: TrapStatementAst.cs プロジェクト: b333z/Pash
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body)
     : base(extent)
 {
     this.TrapType = trapType;
     this.Body = body;
 }
コード例 #17
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw new UnexpectedElementException(); }
コード例 #18
0
ファイル: SemanticChecks.cs プロジェクト: dfinke/powershell
        public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
        {
            CheckArrayTypeNameDepth(typeConstraintAst.TypeName, typeConstraintAst.Extent, _parser);

            return AstVisitAction.Continue;
        }
コード例 #19
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return(AutomationNull.Value);
 }
コード例 #20
0
ファイル: SafeValues.cs プロジェクト: 40a/PowerShell
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw PSTraceSource.NewArgumentException("ast"); }
コード例 #21
0
ファイル: AstVisitor.cs プロジェクト: 40a/PowerShell
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { return CheckParent(ast); }
コード例 #22
0
ファイル: Compiler.cs プロジェクト: 40a/PowerShell
 internal static Attribute GetAttribute(TypeConstraintAst typeConstraintAst)
 {
     Type type = null;
     var ihct = typeConstraintAst.TypeName as ISupportsTypeCaching;
     if (ihct != null)
     {
         type = ihct.CachedType;
     }
     if (type == null)
     {
         type = TypeOps.ResolveTypeName(typeConstraintAst.TypeName, typeConstraintAst.Extent);
         if (ihct != null)
         {
             ihct.CachedType = type;
         }
     }
     return new ArgumentTypeConverterAttribute(type);
 }
コード例 #23
0
 /// <summary/>
 public virtual object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return _decorated.VisitTypeConstraint(typeConstraintAst);
 }
コード例 #24
0
ファイル: Compiler.cs プロジェクト: 40a/PowerShell
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     Diagnostics.Assert(false, "Nothing to generate for a type constraint");
     return null;
 }
コード例 #25
0
ファイル: SourceMapper.cs プロジェクト: gpduck/ScriptMap
    public System.Object VisitTypeConstraint(System.Management.Automation.Language.TypeConstraintAst typeConstraintAst)
    {
        IScriptExtent mappedExtent = MapExtent(typeConstraintAst.Extent);

        return(new TypeConstraintAst(mappedExtent, typeConstraintAst.TypeName));
    }
コード例 #26
0
ファイル: Compiler.cs プロジェクト: 40a/PowerShell
        internal static Expression ConvertValue(TypeConstraintAst typeConstraint, Expression expr)
        {
            var typeName = typeConstraint.TypeName;
            var toType = typeName.GetReflectionType();
            if (toType != null)
            {
                if (toType == typeof(void))
                {
                    return Expression.Block(typeof(void), expr);
                }

                return expr.Convert(toType);
            }

            // typeName can't be resolved at compile time, so defer resolution until runtime.
            return DynamicExpression.Dynamic(PSDynamicConvertBinder.Get(), typeof(object),
                                             Expression.Call(CachedReflectionInfo.TypeOps_ResolveTypeName,
                                                             Expression.Constant(typeName),
                                                             Expression.Constant(typeName.Extent)),
                                             expr);
        }
コード例 #27
0
ファイル: ExecutionVisitor.cs プロジェクト: stangelandcl/Pash
 private bool IsInheritedMatch(TypeConstraintAst typeConstraintAst, Exception ex)
 {
     return (typeConstraintAst != null) && (typeConstraintAst.TypeName.GetReflectionType().IsInstanceOfType(ex));
 }
コード例 #28
0
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast)
 {
     return(Check(ast));
 }
コード例 #29
0
ファイル: AstVisitor.cs プロジェクト: JamesTryand/Pash2
 public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return AstVisitAction.Continue;
 }
コード例 #30
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return false;
 }
コード例 #31
0
ファイル: AstVisitor.cs プロジェクト: 40a/PowerShell
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast)
 {
     Type type = ast.TypeName.GetReflectionType();
     if (type != null)
     {
         Diagnostics.Assert(!(type.GetTypeInfo() is TypeBuilder), "ReflectionType can never be TypeBuilder");
     }
     return AstVisitAction.Continue;
 }
コード例 #32
0
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     DispatchTypeName(typeConstraintAst.TypeName, genericArgumentCount: 0, isAttribute: false);
     return(AstVisitAction.Continue);
 }
コード例 #33
0
 public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     this.CheckTypeName(typeConstraintAst, typeConstraintAst.TypeName);
     return AstVisitAction.Continue;
 }
コード例 #34
0
 /// <summary/>
 public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) => DefaultVisit(typeConstraintAst);
コード例 #35
0
 /// <summary/>
 public virtual object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return(null);
 }
コード例 #36
0
ファイル: VariableAnalysis.cs プロジェクト: nickchal/pash
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return null;
 }
コード例 #37
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     throw PSTraceSource.NewArgumentException("ast");
 }
コード例 #38
0
ファイル: ConvertExpressionAst.cs プロジェクト: mauve/Pash
 public ConvertExpressionAst(IScriptExtent extent, TypeConstraintAst typeConstraint, ExpressionAst child)
     : base(extent, typeConstraint, child)
 {
     this.Type = typeConstraint;
 }
コード例 #39
0
 /// <summary/>
 public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return(AstVisitAction.Continue);
 }
コード例 #40
0
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body)
     : base(extent)
 {
     this.TrapType = trapType;
     this.Body     = body;
 }
コード例 #41
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     return(false);
 }
コード例 #42
0
 public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst)
 {
     throw new NotImplementedException();
 }