Пример #1
0
        public LambdaFunctionExpr(SourceUnit/*!*/ sourceUnit,
            Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
            Scope scope, NamespaceDecl ns,
            bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalParam> useParams,
            List<Statement>/*!*/ body)
            : base(position)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                else
                    formalParams.InsertRange(0, useParams);
            }
            
            //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;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;

            //QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);
            //function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
            function = new PhpLambdaFunction(this.signature, sourceUnit, position);
            function.WriteUp(new TypeSignature(FormalTypeParam.EmptyList).ToPhpRoutineSignature(function));
        }
Пример #2
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,
            List<Statement>/*!*/ body)
            : base(span)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                else
                    formalParams.InsertRange(0, useParams);
            }
            
            //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;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
        }
Пример #3
0
        public FunctionDecl(SourceUnit /*!*/ sourceUnit,
                            Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
                            bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, string /*!*/ name, NamespaceDecl ns,
                            bool aliasReturn, List <FormalParam> /*!*/ formalParams, List <FormalTypeParam> /*!*/ genericParams,
                            List <Statement> /*!*/ body, List <CustomAttribute> attributes)
            : base(position)
        {
            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);
            this.attributes                = new CustomAttributes(attributes);
            this.body                      = body;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition        = headingEndPosition;
            this.declarationBodyPosition   = declarationBodyPosition;

            QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);

            function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
            function.WriteUp(typeSignature.ToPhpRoutineSignature(function));

            function.Declaration.Node = this;
        }
Пример #4
0
 public GlobalConstantDecl(SourceUnit /*!*/ sourceUnit, Text.Span span, bool isConditional, Scope scope,
                           string /*!*/ name, NamespaceDecl ns, Expression /*!*/ initializer)
     : base(span, name, initializer)
 {
     this.ns            = ns;
     this.IsConditional = IsConditional;
     this.Scope         = scope;
     this.SourceUnit    = sourceUnit;
 }
Пример #5
0
        public GlobalConstantDecl(SourceUnit /*!*/ sourceUnit, Position position, bool isConditional, Scope scope,
                                  string /*!*/ name, NamespaceDecl ns, Expression /*!*/ initializer)
            : base(position, name, initializer)
        {
            this.ns = ns;

            QualifiedName qn = (ns != null) ? new QualifiedName(new Name(name), ns.QualifiedName) : new QualifiedName(new Name(name));

            constant = new GlobalConstant(qn, PhpMemberAttributes.Public, sourceUnit, isConditional, scope, position);

            constant.SetNode(this);
        }
Пример #6
0
        public TypeDecl(SourceUnit /*!*/ sourceUnit,
                        Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
                        bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, bool isPartial, Name className, Text.Span classNamePosition,
                        NamespaceDecl ns, List <FormalTypeParam> /*!*/ genericParams, Tuple <GenericQualifiedName, Text.Span> baseClassName,
                        List <Tuple <GenericQualifiedName, Text.Span> > /*!*/ implementsList, List <TypeMemberDecl> /*!*/ elements,
                        List <CustomAttribute> attributes)
            : 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.name          = className;
            this.NamePosition  = classNamePosition;
            this.ns            = ns;
            this.typeSignature = new TypeSignature(genericParams);
            if (baseClassName != null)
            {
                this.baseClassName         = baseClassName.Item1;
                this.BaseClassNamePosition = baseClassName.Item2;
            }
            this.MemberAttributes = memberAttributes;
            this.Scope            = scope;
            this.SourceUnit       = sourceUnit;
            this.IsConditional    = isConditional;
            if (implementsList == null || implementsList.Count == 0)
            {
                this.ImplementsList         = EmptyArray <GenericQualifiedName> .Instance;
                this.ImplementsListPosition = EmptyArray <Text.Span> .Instance;
            }
            else
            {
                this.ImplementsList         = implementsList.Select(x => x.Item1).ToArray();
                this.ImplementsListPosition = implementsList.Select(x => x.Item2).ToArray();
            }
            this.members = elements;
            this.members.TrimExcess();

            if (attributes != null && attributes.Count != 0)
            {
                this.Attributes = new CustomAttributes(attributes);
            }
            this.entireDeclarationSpan   = entireDeclarationPosition;
            this.headingEndPosition      = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;
            this.partialKeyword          = isPartial;
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
0
        public LambdaFunctionExpr(SourceUnit /*!*/ sourceUnit,
                                  Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
                                  Scope scope, NamespaceDecl ns,
                                  bool aliasReturn, List <FormalParam> /*!*/ formalParams, List <FormalParam> useParams,
                                  List <Statement> /*!*/ body)
            : base(position)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                {
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                }
                else
                {
                    formalParams.InsertRange(0, useParams);
                }
            }

            //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;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition        = headingEndPosition;
            this.declarationBodyPosition   = declarationBodyPosition;

            //QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);
            //function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
            function = new PhpLambdaFunction(this.signature, sourceUnit, position);
            function.WriteUp(new TypeSignature(FormalTypeParam.EmptyList).ToPhpRoutineSignature(function));
        }
Пример #10
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;
		}
Пример #11
0
		public FunctionDecl(SourceUnit/*!*/ sourceUnit,
            Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
			bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, string/*!*/ name, NamespaceDecl ns,
			bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalTypeParam>/*!*/ genericParams,
			List<Statement>/*!*/ body, List<CustomAttribute> attributes)
			: base(position)
		{
			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);
			this.attributes = new CustomAttributes(attributes);
			this.body = body;
			this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;

			QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);
			function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
			function.WriteUp(typeSignature.ToPhpRoutineSignature(function));

			function.Declaration.Node = this;
		}
Пример #12
0
 /// <summary>
 /// Visit namespace statements.
 /// </summary>
 /// <param name="x"></param>
 virtual public void VisitNamespaceDecl(NamespaceDecl x)
 {
     VisitStatementList(x.Statements);
 }
Пример #13
0
 /// <summary>
 /// Visit namespace statements.
 /// </summary>
 /// <param name="x"></param>
 virtual public void VisitNamespaceDecl(NamespaceDecl x)
 {
     VisitStatements(x.Statements);
 }
Пример #14
0
 public void NamespaceDeclReduced(Parser parser, NamespaceDecl decl)
 {
 }
Пример #15
0
		public GlobalConstantDecl(SourceUnit/*!*/ sourceUnit, Position position, bool isConditional, Scope scope,
			string/*!*/ name, NamespaceDecl ns, Expression/*!*/ initializer)
			: base(position, name, initializer)
		{
			this.ns = ns;

			QualifiedName qn = (ns != null) ? new QualifiedName(new Name(name), ns.QualifiedName) : new QualifiedName(new Name(name));
			constant = new GlobalConstant(qn, PhpMemberAttributes.Public, sourceUnit, isConditional, scope, position);

			constant.SetNode(this);
		}
Пример #16
0
		internal void EnterNamespace(NamespaceDecl ns)
		{
			Debug.Assert(!currentNamespace.HasValue, "Namespace nesting not supported");
			currentNamespace = ns.QualifiedName;
		}
Пример #17
0
		public TypeDecl(SourceUnit/*!*/ sourceUnit,
			Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
			bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, bool isPartial, Name className, Position classNamePosition,
			NamespaceDecl ns, List<FormalTypeParam>/*!*/ genericParams, Tuple<GenericQualifiedName, Position> baseClassName,
			List<KeyValuePair<GenericQualifiedName, Position>>/*!*/ implementsList, List<TypeMemberDecl>/*!*/ members,
			List<CustomAttribute> attributes)
			: base(position)
		{
			Debug.Assert(genericParams != null && implementsList != null && members != null);
            Debug.Assert((memberAttributes & PhpMemberAttributes.Trait) == 0 || (memberAttributes & PhpMemberAttributes.Interface) == 0, "Interface cannot be a trait");

			this.name = className;
            this.NamePosition = classNamePosition;
			this.ns = ns;
			this.typeSignature = new TypeSignature(genericParams);
            if (baseClassName != null)
            {
                this.baseClassName = baseClassName.Item1;
                this.BaseClassNamePosition = baseClassName.Item2;
            }
            this.implementsList = implementsList;
			this.members = members;
			this.attributes = new CustomAttributes(attributes);
			this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
			this.declarationBodyPosition = declarationBodyPosition;
            this.partialKeyword = isPartial;

            // remember current aliases:
            var aliases = (ns != null) ? ns.Aliases : sourceUnit.Aliases;
            if (aliases.Count > 0)
                validAliases = new Dictionary<string, QualifiedName>(aliases);

			// create stuff necessary for inclusion resolving process, other structures are created duirng analysis:
			QualifiedName qn = (ns != null) ? new QualifiedName(name, ns.QualifiedName) : new QualifiedName(name);
			type = new PhpType(qn, memberAttributes, isPartial, typeSignature, isConditional, scope, sourceUnit, position);

            //// add alias for private classes (if not added yet by partial declaration):
            //if (type.IsPrivate)
            //    sourceUnit.AddTypeAlias(qn, this.name);

			// member-analysis needs the node:
			type.Declaration.Node = this;
		}
Пример #18
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;
		}
Пример #19
0
		public TypeDecl(SourceUnit/*!*/ sourceUnit,
            Text.Span span, Text.Span entireDeclarationPosition, int headingEndPosition, int declarationBodyPosition,
            bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, bool isPartial, Name className, Text.Span classNamePosition,
            NamespaceDecl ns, List<FormalTypeParam>/*!*/ genericParams, Tuple<GenericQualifiedName, Text.Span> baseClassName,
            List<Tuple<GenericQualifiedName, Text.Span>>/*!*/ implementsList, List<TypeMemberDecl>/*!*/ elements,
			List<CustomAttribute> attributes)
            : 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.name = className;
            this.NamePosition = classNamePosition;
			this.ns = ns;
			this.typeSignature = new TypeSignature(genericParams);
            if (baseClassName != null)
            {
                this.baseClassName = baseClassName.Item1;
                this.BaseClassNamePosition = baseClassName.Item2;
            }
            this.MemberAttributes = memberAttributes;
            this.Scope = scope;
            this.SourceUnit = sourceUnit;
            this.IsConditional = isConditional;
            if (implementsList == null || implementsList.Count == 0)
            {
                this.ImplementsList = EmptyArray<GenericQualifiedName>.Instance;
                this.ImplementsListPosition = EmptyArray<Text.Span>.Instance;
            }
            else
            {
                this.ImplementsList = implementsList.Select(x => x.Item1).ToArray();
                this.ImplementsListPosition = implementsList.Select(x => x.Item2).ToArray();
            }
            this.members = elements;
            this.members.TrimExcess();

			if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);
			this.entireDeclarationSpan = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
			this.declarationBodyPosition = declarationBodyPosition;
            this.partialKeyword = isPartial;
		}
Пример #20
0
 public GlobalConstantDecl(SourceUnit/*!*/ sourceUnit, Text.Span span, bool isConditional, Scope scope,
     string/*!*/ name, NamespaceDecl ns, Expression/*!*/ initializer)
     : base(span, name, initializer)
 {
     this.ns = ns;
     this.IsConditional = IsConditional;
     this.Scope = scope;
     this.SourceUnit = sourceUnit;
 }
Пример #21
0
		public TypeDecl(SourceUnit/*!*/ sourceUnit,
			Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
			bool isConditional, Scope scope, PhpMemberAttributes memberAttributes, bool isPartial, Name className, Position classNamePosition,
			NamespaceDecl ns, List<FormalTypeParam>/*!*/ genericParams, Tuple<GenericQualifiedName, Position> baseClassName,
			List<KeyValuePair<GenericQualifiedName, Position>>/*!*/ implementsList, List<TypeMemberDecl>/*!*/ members,
			List<CustomAttribute> attributes)
			: base(position)
		{
			Debug.Assert(genericParams != null && implementsList != null && members != null);
            Debug.Assert((memberAttributes & PhpMemberAttributes.Trait) == 0 || (memberAttributes & PhpMemberAttributes.Interface) == 0, "Interface cannot be a trait");

			this.name = className;
            this.NamePosition = classNamePosition;
			this.ns = ns;
			this.typeSignature = new TypeSignature(genericParams);
            if (baseClassName != null)
            {
                this.baseClassName = baseClassName.Item1;
                this.BaseClassNamePosition = baseClassName.Item2;
            }
            this.MemberAttributes = memberAttributes;
            this.Scope = scope;
            this.SourceUnit = sourceUnit;
            this.IsConditional = isConditional;
            this.implementsList = implementsList;
			this.members = members;
			if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);
			this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
			this.declarationBodyPosition = declarationBodyPosition;
            this.partialKeyword = isPartial;

            // remember current aliases:
            var aliases = (ns != null) ? ns.Aliases : sourceUnit.Aliases;
            if (aliases.Count > 0)
                validAliases = new Dictionary<string, QualifiedName>(aliases);
		}