Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the GlobalCode class.
        /// </summary>
        public GlobalCode(IList <Statement> /*!*/ statements, SourceUnit /*!*/ sourceUnit)
        {
            Debug.Assert(statements != null && sourceUnit != null);

            this.sourceUnit = sourceUnit;
            this.statements = statements.AsArray();
        }
Exemplo n.º 2
0
        public FunctionDecl(SourceUnit /*!*/ sourceUnit,
                            Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
                            bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, string /*!*/ name, NamespaceDecl ns,
                            bool aliasReturn, List <FormalParam> /*!*/ formalParams, List <FormalTypeParam> /*!*/ genericParams,
                            IList <Statement> /*!*/ body, List <CustomAttribute> attributes)
            : base(span)
        {
            Debug.Assert(genericParams != null && name != null && formalParams != null && body != null);

            this.name          = new Name(name);
            this.ns            = ns;
            this.signature     = new Signature(aliasReturn, formalParams);
            this.typeSignature = new TypeSignature(genericParams);
            if (attributes != null && attributes.Count != 0)
            {
                this.Attributes = new CustomAttributes(attributes);
            }
            this.body = body.AsArray();
            this.entireDeclarationSpan   = entireDeclarationPosition;
            this.headingEndPosition      = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
            this.IsConditional           = isConditional;
            this.MemberAttributes        = memberAttributes;
            this.Scope      = scope;
            this.SourceUnit = sourceUnit;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the GlobalCode class.
        /// </summary>
        public GlobalCode(Text.Span span, IList <Statement> /*!*/ statements, SourceUnit /*!*/ sourceUnit) : base(span)
        {
            Debug.Assert(statements != null && sourceUnit != null);

            this.sourceUnit = sourceUnit;
            this.statements = statements.AsArray();
        }
Exemplo n.º 4
0
 public EchoStmt(Text.Span span, IList <Expression> /*!*/ parameters)
     : base(span)
 {
     Debug.Assert(parameters != null);
     this.parameters = parameters.AsArray();
     this.isHtmlCode = false;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the GlobalCode class.
        /// </summary>
        public GlobalCode(IList<Statement>/*!*/ statements, SourceUnit/*!*/ sourceUnit)
        {
            Debug.Assert(statements != null && sourceUnit != null);

            this.sourceUnit = sourceUnit;
            this.statements = statements.AsArray();
        }
Exemplo n.º 6
0
		public EchoStmt(Text.Span span, IList<Expression>/*!*/ parameters)
            : base(span)
		{
			Debug.Assert(parameters != null);
			this.parameters = parameters.AsArray();
            this.isHtmlCode = false;
		}
Exemplo n.º 7
0
        private ArrayEx(Text.Span span, IList <Item> items, Flags flags)
            : base(span)
        {
            Debug.Assert(flags != 0);

            _items = items.AsArray();
            _flags = flags;
        }
Exemplo n.º 8
0
        public SwitchStmt(Text.Span span, Expression /*!*/ switchValue, IList <SwitchItem> /*!*/ switchItems)
            : base(span)
        {
            Debug.Assert(switchValue != null && switchItems != null);

            this.switchValue = switchValue;
            this.switchItems = switchItems.AsArray();
        }
Exemplo n.º 9
0
        public UseStatement(Span span, IList <UseBase> uses, AliasKind kind)
            : base(span)
        {
            Debug.Assert(uses != null);

            _kind = kind;
            _uses = uses.AsArray();
        }
Exemplo n.º 10
0
        public MultipleTypeRef(Span span, IList <TypeRef> /*!*/ multipleTypes)
            : base(span)
        {
            Debug.Assert(multipleTypes != null);
            Debug.Assert(multipleTypes.All(x => x != null));

            _types = multipleTypes.AsArray();
        }
Exemplo n.º 11
0
		public SwitchStmt(Text.Span span, Expression/*!*/ switchValue, IList<SwitchItem>/*!*/ switchItems)
			: base(span)
		{
			Debug.Assert(switchValue != null && switchItems != null);

			this.switchValue = switchValue;
			this.switchItems = switchItems.AsArray();
		}
Exemplo n.º 12
0
        public TryStmt(Text.Span p, IList <Statement> /*!*/ statements, List <CatchItem> catches, FinallyItem finallyItem)
            : base(p)
        {
            Debug.Assert(statements != null);

            this.statements  = statements.AsArray();
            this.catches     = catches.AsArray();
            this.finallyItem = finallyItem;
        }
Exemplo n.º 13
0
        public TryStmt(Text.Span p, BlockStmt /*!*/ body, IList <CatchItem> catches, FinallyItem finallyItem)
            : base(p)
        {
            Debug.Assert(body != null);

            this.body        = body;
            this.catches     = catches.AsArray();
            this.finallyItem = finallyItem;
        }
Exemplo n.º 14
0
        public TryStmt(Text.Span p, IList<Statement>/*!*/ statements, List<CatchItem> catches, FinallyItem finallyItem)
			: base(p)
		{
            Debug.Assert(statements != null);
            
			this.statements = statements.AsArray();
			this.catches = catches.AsArray();
            this.finallyItem = finallyItem;
		}
Exemplo n.º 15
0
        public GroupUse(Span span, QualifiedNameRef prefix, IList <SimpleUse> uses)
            : base(span)
        {
            Debug.Assert(span.IsValid);
            Debug.Assert(uses != null);

            _prefix = prefix;
            _uses   = uses.AsArray();
        }
Exemplo n.º 16
0
        public CatchItem(Text.Span p, DirectTypeRef tref, DirectVarUse /*!*/ variable,
                         IList <Statement> /*!*/ statements)
            : base(p)
        {
            Debug.Assert(variable != null && statements != null);

            this.tref       = tref;
            this.variable   = variable;
            this.statements = statements.AsArray();
        }
Exemplo n.º 17
0
        public CatchItem(Text.Span p, GenericQualifiedName className, DirectVarUse /*!*/ variable,
                         IList <Statement> /*!*/ statements)
            : base(p)
        {
            Debug.Assert(variable != null && statements != null);

            this.className  = className;
            this.variable   = variable;
            this.statements = statements.AsArray();
        }
Exemplo n.º 18
0
            public IEnumerable <TypeDeclarationSyntax> GetTypes(SyntaxNode namespaceNode)
            {
                var node = namespaceNode as NamespaceDeclarationSyntax;

                if (node != null)
                {
                    Visit(node);
                }

                return(_types.AsArray());
            }
Exemplo n.º 19
0
 public TraitsUse(Text.Span span, IList <TypeRef> /*!*/ traitsList, TraitAdaptationBlock traitAdaptationBlock)
     : base(span, PhpMemberAttributes.Public)
 {
     if (traitsList == null)
     {
         throw new ArgumentNullException("traitsList");
     }
     Debug.Assert(traitsList.All(t => t is INamedTypeRef));
     this.traitsList           = traitsList.AsArray();
     this.traitAdaptationBlock = traitAdaptationBlock;
 }
        public IEnumerable <NamespaceDeclarationSyntax> GetNamespaces(SyntaxNode commonNode)
        {
            var node = commonNode as SyntaxNode;

            if (node != null)
            {
                Visit(node);
            }

            return(_namespaces.AsArray());
        }
Exemplo n.º 21
0
        public ListEx(Text.Span p, IList <Item> /*!*/ lvalues)
            : base(p)
        {
            Debug.Assert(lvalues != null);
            //Debug.Assert(lvalues.All(item => item is ValueItem && (
            //    ((ValueItem)item).ValueExpr == null ||
            //    ((ValueItem)item).ValueExpr is VarLikeConstructUse ||
            //    ((ValueItem)item).ValueExpr is ListEx)));

            _items = lvalues.AsArray();
        }
Exemplo n.º 22
0
        public ForStmt(Text.Span p,
                       IList <Expression> /*!*/ initExList, IList <Expression> /*!*/ condExList, IList <Expression> /*!*/ actionExList,
                       Text.Span conditionSpan, Statement /*!*/ body)
            : base(p)
        {
            Debug.Assert(initExList != null && condExList != null && actionExList != null && body != null);

            this.initExList     = initExList.AsArray();
            this.condExList     = condExList.AsArray();
            this.actionExList   = actionExList.AsArray();
            this.body           = body;
            this._conditionSpan = conditionSpan;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Create new method declaration.
        /// </summary>
        /// <param name="span">Entire span.</param>
        /// <param name="name">Method name.</param>
        /// <param name="aliasReturn"><c>true</c> if method returns alias, <c>false</c> otherwise.</param>
        /// <param name="formalParams">Parameters.</param>
        /// <param name="paramsSpan">Span of the parameters including parentheses.</param>
        /// <param name="genericParams">Generic parameters.</param>
        /// <param name="body">Method content.</param>
        /// <param name="modifiers">Method modifiers, visibility etc.</param>
        /// <param name="baseCtorParams">Parameters for the base class constructor.</param>
        /// <param name="returnType">Return type hint, optional.</param>
        public MethodDecl(Text.Span span,
                          NameRef name, bool aliasReturn, IList <FormalParam> /*!*/ formalParams, Text.Span paramsSpan,
                          IList <FormalTypeParam> /*!*/ genericParams, BlockStmt body,
                          PhpMemberAttributes modifiers, IList <ActualParam> baseCtorParams, TypeRef returnType)
            : base(span, modifiers)
        {
            Debug.Assert(genericParams != null && formalParams != null);

            this.name           = name;
            this.signature      = new Signature(aliasReturn, formalParams, paramsSpan);
            this.typeSignature  = new TypeSignature(genericParams);
            this.body           = body;
            this.baseCtorParams = baseCtorParams.AsArray();
            this.returnType     = returnType;
        }
Exemplo n.º 24
0
        public MethodDecl(Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
                          string name, bool aliasReturn, IList <FormalParam> /*!*/ formalParams, IList <FormalTypeParam> /*!*/ genericParams,
                          IList <Statement> body, PhpMemberAttributes modifiers, IList <ActualParam> baseCtorParams,
                          List <CustomAttribute> attributes)
            : base(span, attributes)
        {
            Debug.Assert(genericParams != null && formalParams != null);

            this.modifiers               = modifiers;
            this.name                    = new Name(name);
            this.signature               = new Signature(aliasReturn, formalParams);
            this.typeSignature           = new TypeSignature(genericParams);
            this.body                    = (body != null) ? body.AsArray() : null;
            this.baseCtorParams          = (baseCtorParams != null) ? baseCtorParams.AsArray() : null;
            this.entireDeclarationSpan   = entireDeclarationPosition;
            this.headingEndPosition      = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
Exemplo n.º 25
0
        public SyntaxDeclarations GetDeclarations(IEnumerable <SyntaxTree> trees)
        {
            var syntaxTrees = trees.AsArray();

            foreach (var root in syntaxTrees.Select(syntaxTree => syntaxTree.GetRoot()))
            {
                Visit(root);
                CheckStatementSyntax(root);
            }

            return(new SyntaxDeclarations
            {
                MemberDeclarations = _members.AsArray(),
                NamespaceDeclarations = _namespaces.AsArray(),
                Statements = _statements.AsArray(),
                TypeDeclarations = _types.AsArray()
            });
        }
Exemplo n.º 26
0
        public TypeDecl(
            Text.Span span, Text.Span headingSpan,
            bool isConditional, PhpMemberAttributes memberAttributes, bool isPartial,
            IList <FormalTypeParam> /*!*/ genericParams, INamedTypeRef baseClass,
            IList <INamedTypeRef> /*!*/ implementsList, IList <TypeMemberDecl> /*!*/ elements, Text.Span bodySpan)
            : base(span)
        {
            Debug.Assert(genericParams != null && implementsList != null && elements != null);
            Debug.Assert((memberAttributes & PhpMemberAttributes.Trait) == 0 || (memberAttributes & PhpMemberAttributes.Interface) == 0, "Interface cannot be a trait");

            this.typeSignature    = new TypeSignature(genericParams);
            this.baseClass        = baseClass;
            this.MemberAttributes = memberAttributes;
            this.IsConditional    = isConditional;
            this.ImplementsList   = implementsList.AsArray();
            this.members          = elements.AsArray();
            this.headingSpan      = headingSpan;
            this.bodySpan         = bodySpan;
            this.partialKeyword   = isPartial;
        }
Exemplo n.º 27
0
        public LambdaFunctionExpr(SourceUnit /*!*/ sourceUnit,
                                  Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
                                  Scope scope, NamespaceDecl ns,
                                  bool aliasReturn, List <FormalParam> /*!*/ formalParams, List <FormalParam> useParams,
                                  IList <Statement> /*!*/ body)
            : base(span)
        {
            Debug.Assert(formalParams != null && body != null);
            Debug.Assert(sourceUnit != null);

            this.sourceUnit = sourceUnit;

            this.ns        = ns;
            this.signature = new Signature(aliasReturn, formalParams);
            this.useParams = useParams;
            //this.typeSignature = new TypeSignature(genericParams);
            //this.attributes = new CustomAttributes(attributes);
            this.body = body.AsArray();
            this.entireDeclarationSpan   = entireDeclarationPosition;
            this.headingEndPosition      = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
Exemplo n.º 28
0
 public Signature(bool aliasReturn, IList <FormalParam> /*!*/ formalParams)
 {
     this.aliasReturn  = aliasReturn;
     this.formalParams = formalParams.AsArray();
 }
Exemplo n.º 29
0
 /// <summary>
 /// Initialize the ConcatEx AST node and optimize the subtree if possible. Look for child expressions and chain possible concatenations. This prevents StackOverflowException in case of huge concatenation expressions.
 /// </summary>
 /// <param name="span"></param>
 /// <param name="expressions">List of expressions to concatenate.</param>
 /// <remarks>This method tries to propagate child concatenations and chain them.</remarks>
 public ConcatEx(Text.Span span, IList<Expression>/*!*/ expressions)
     : base(span)
 {
     Debug.Assert(expressions != null);
     this.expressions = expressions.AsArray();
 }
Exemplo n.º 30
0
		public ArrayEx(Text.Span span, IList<Item>/*!*/items)
			: base(span)
		{
			Debug.Assert(items != null);
			this.items = items.AsArray();
		}
Exemplo n.º 31
0
		protected SwitchItem(Text.Span span, IList<Statement>/*!*/ statements)
			: base(span)
		{
			Debug.Assert(statements != null);
			this.statements = statements.AsArray();
		}
Exemplo n.º 32
0
 /// <summary>
 /// Initialize new instance of <see cref="CallSignature"/>.
 /// </summary>
 /// <param name="parameters">List of parameters.</param>
 /// <param name="genericParams">List of type parameters for generics.</param>
 public CallSignature(IList <ActualParam> parameters, IList <TypeRef> genericParams)
 {
     this.parameters    = parameters.AsArray();
     this.GenericParams = genericParams.AsArray();
 }
Exemplo n.º 33
0
        public MethodDecl(Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition, 
			string name, bool aliasReturn, IList<FormalParam>/*!*/ formalParams, IList<FormalTypeParam>/*!*/ genericParams, 
			IList<Statement> body, PhpMemberAttributes modifiers, IList<ActualParam> baseCtorParams, 
			List<CustomAttribute> attributes)
            : base(span, attributes)
        {
            Debug.Assert(genericParams != null && formalParams != null);

            this.modifiers = modifiers;
            this.name = new Name(name);
            this.signature = new Signature(aliasReturn, formalParams);
            this.typeSignature = new TypeSignature(genericParams);
            this.body = (body != null) ? body.AsArray() : null;
            this.baseCtorParams = (baseCtorParams != null) ? baseCtorParams.AsArray() : null;
            this.entireDeclarationSpan = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
Exemplo n.º 34
0
 public TraitAdaptationBlock(Text.Span span, IList <TraitsUse.TraitAdaptation> /*!*/ body)
     : base(span)
 {
     Debug.Assert(body != null);
     _adaptations = body.AsArray();
 }
Exemplo n.º 35
0
 public TypeSignature(IList <FormalTypeParam> /*!!*/ typeParams)
 {
     Debug.Assert(typeParams != null);
     this.typeParams = typeParams.AsArray();
 }
Exemplo n.º 36
0
 public BlockStmt(Text.Span span, IList <Statement> /*!*/ body)
     : base(span)
 {
     Debug.Assert(body != null);
     _statements = body.AsArray();
 }
Exemplo n.º 37
0
		public FunctionDecl(SourceUnit/*!*/ sourceUnit,
            Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
			bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, string/*!*/ name, NamespaceDecl ns,
			bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalTypeParam>/*!*/ genericParams,
			IList<Statement>/*!*/ body, List<CustomAttribute> attributes)
			: base(span)
		{
			Debug.Assert(genericParams != null && name != null && formalParams != null && body != null);

			this.name = new Name(name);
			this.ns = ns;
			this.signature = new Signature(aliasReturn, formalParams);
			this.typeSignature = new TypeSignature(genericParams);
			if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);
			this.body = body.AsArray();
			this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
            this.IsConditional = isConditional;
            this.MemberAttributes = memberAttributes;
            this.Scope = scope;
            this.SourceUnit = sourceUnit;
		}
Exemplo n.º 38
0
		public Signature(bool aliasReturn, IList<FormalParam>/*!*/ formalParams)
		{
			this.aliasReturn = aliasReturn;
			this.formalParams = formalParams.AsArray();
		}
Exemplo n.º 39
0
		public TypeSignature(IList<FormalTypeParam>/*!!*/ typeParams)
		{
			Debug.Assert(typeParams != null);
			this.typeParams = typeParams.AsArray();
		}
Exemplo n.º 40
0
        /// <summary>
        /// Initialize new instance of <see cref="CallSignature"/>.
        /// </summary>
        /// <param name="parameters">List of parameters.</param>
        /// <param name="genericParams">List of type parameters for generics.</param>
        public CallSignature(IList<ActualParam> parameters, IList<TypeRef> genericParams)
		{
			this.parameters = parameters.AsArray();
            this.GenericParams = genericParams.AsArray();
		}        
Exemplo n.º 41
0
        public CatchItem(Text.Span p, DirectTypeRef tref, DirectVarUse/*!*/ variable,
			IList<Statement>/*!*/ statements)
			: base(p)
		{
			Debug.Assert(variable != null && statements != null);

			this.tref = tref;
			this.variable = variable;
			this.statements = statements.AsArray();
		}
Exemplo n.º 42
0
 public BlockStmt(Text.Span span, IList<Statement>/*!*/body)
     : base(span)
 {
     Debug.Assert(body != null);
     _statements = body.AsArray();
 }
Exemplo n.º 43
0
 public TraitAdaptationPrecedence(Text.Span span, Tuple <TypeRef, NameRef> traitMemberName, IList <TypeRef> /*!*/ ignoredTypes)
     : base(span, traitMemberName)
 {
     this.IgnoredTypes = ignoredTypes.AsArray();
 }
Exemplo n.º 44
0
        public LambdaFunctionExpr(SourceUnit/*!*/ sourceUnit,
            Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
            Scope scope, NamespaceDecl ns,
            bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalParam> useParams,
            IList<Statement>/*!*/ body)
            : base(span)
        {
            Debug.Assert(formalParams != null && body != null);
            Debug.Assert(sourceUnit != null);

            this.sourceUnit = sourceUnit;
            
            this.ns = ns;
            this.signature = new Signature(aliasReturn, formalParams);
            this.useParams = useParams;
            //this.typeSignature = new TypeSignature(genericParams);
            //this.attributes = new CustomAttributes(attributes);
            this.body = body.AsArray();
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
Exemplo n.º 45
0
 public FinallyItem(Text.Span span, IList<Statement>/*!*/statements)
     : base(span)
 {
     this.statements = statements.AsArray();
 }
Exemplo n.º 46
0
 /// <summary>
 /// Initialize the ConcatEx AST node and optimize the subtree if possible. Look for child expressions and chain possible concatenations. This prevents StackOverflowException in case of huge concatenation expressions.
 /// </summary>
 /// <param name="span"></param>
 /// <param name="expressions">List of expressions to concatenate.</param>
 /// <remarks>This method tries to propagate child concatenations and chain them.</remarks>
 public ConcatEx(Text.Span span, IList <Expression> /*!*/ expressions)
     : base(span)
 {
     Debug.Assert(expressions != null);
     this.expressions = expressions.AsArray();
 }