예제 #1
0
파일: TypeDecl.cs 프로젝트: Ashod/Phalanger
		public FormalTypeParam(Position position, Name name, object defaultType, List<CustomAttribute> attributes)
			: base(position)
		{
			this.name = name;
			this.defaultType = defaultType;
			this.attributes = new CustomAttributes(attributes);
		}
예제 #2
0
		public FormalTypeParam(Text.Span span, Name name, object defaultType, List<CustomAttribute> attributes)
            : base(span)
		{
            Debug.Assert(defaultType == null || defaultType is PrimitiveTypeName || defaultType is GenericQualifiedName);

			this.name = name;
			this.defaultType = defaultType;

			if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);
		}
예제 #3
0
        internal static void Merge(AstNode node, CustomAttributes otherattributes)
        {
            if (otherattributes != null)
            {
                var attributes = node.GetCustomAttributes();
                if (attributes == null)
                    node.SetCustomAttributes(attributes = new CustomAttributes(null));

                attributes.Merge(otherattributes);
            }
        }
예제 #4
0
		internal void Merge(CustomAttributes other)
		{
			if (other.attributes == null)
				return;

			if (attributes == null)
			{
				attributes = other.attributes;
				return;
			}

			attributes.AddRange(other.attributes);

			other.attributes = null;
		}
예제 #5
0
        internal void Merge(CustomAttributes other)
        {
            if (other == null || other.attributes == null)
                return;

            if (attributes == null || attributes.Count == 0)
            {
                attributes = other.attributes;
            }
            else
            {
                attributes.AddRange(other.attributes);
            }

            other.attributes = null;
        }
예제 #6
0
        protected TypeMemberDecl(Position position, List<CustomAttribute> attributes)
			: base(position)
		{
            if (attributes != null && attributes.Count != 0)
			    this.Attributes = new CustomAttributes(attributes);
		}
예제 #7
0
		public GlobalConstDeclList(Position position, List<GlobalConstantDecl>/*!*/ constants,
	  List<CustomAttribute> attributes, string docComment)
			: base(position)
		{
			Debug.Assert(constants != null);

			this.constants = constants;
			this.docComment = docComment;
			this.attributes = new CustomAttributes(attributes);
		}
예제 #8
0
 public static void SetCustomAttributes(this IPropertyCollection/*!*/properties, CustomAttributes attributes)
 {
     if (attributes != null)
         properties[typeof(CustomAttributes)] = attributes;
     else
         properties.RemoveProperty(typeof(CustomAttributes));
 }
예제 #9
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;
		}
예제 #10
0
		public FormalParam(Position position, string/*!*/ name, object typeHint, bool passedByRef,
				Expression initValue, List<CustomAttribute> attributes)
			: base(position)
		{
			this.name = new VariableName(name);
			this.typeHint = typeHint;
			this.passedByRef = passedByRef;
			this.initValue = initValue;
			this.attributes = new CustomAttributes(attributes);

			this.resolvedTypeHint = null;
		}
예제 #11
0
파일: TypeDecl.cs 프로젝트: Ashod/Phalanger
		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;
		}
예제 #12
0
        public FormalParam(Text.Span span, string/*!*/ name, object typeHint, Flags flags,
				Expression initValue, List<CustomAttribute> attributes)
            : base(span)
		{
            Debug.Assert(typeHint == null || typeHint is PrimitiveTypeName || typeHint is GenericQualifiedName);

			this.name = new VariableName(name);
			this.typeHint = typeHint;
            this._flags = flags;
			this.initValue = initValue;
            if (attributes != null && attributes.Count != 0)
                this.Attributes = new CustomAttributes(attributes);

			this.TypeHintPosition = Text.Span.Invalid;
		}
예제 #13
0
파일: TypeDecl.cs 프로젝트: Ashod/Phalanger
        protected TypeMemberDecl(Position position, List<CustomAttribute> attributes)
			: base(position)
		{
			this.attributes = new CustomAttributes(attributes);
		}
예제 #14
0
        protected TypeMemberDecl(Text.Span span, List<CustomAttribute> attributes)
            : base(span)
		{
            if (attributes != null && attributes.Count != 0)
			    this.Attributes = new CustomAttributes(attributes);
		}
예제 #15
0
 public static void SetCustomAttributes(this IPropertyCollection /*!*/ properties, CustomAttributes attributes)
 {
     if (attributes != null)
     {
         properties[typeof(CustomAttributes)] = attributes;
     }
     else
     {
         properties.RemoveProperty(typeof(CustomAttributes));
     }
 }
예제 #16
0
            public void Emit(CustomAttributes/*!*/node, CodeGenerator/*!*/ codeGenerator, IPhpCustomAttributeProvider/*!*/ target)
            {
                if (node.Attributes == null) return;

                foreach (CustomAttribute attribute in node.Attributes)
                    attribute.Emit(codeGenerator, target);
            }
예제 #17
0
            public int Count(CustomAttributes/*!*/node, DType/*!*/ attributeType, CustomAttribute.TargetSelectors selector)
            {
                if (node.Attributes == null) return 0;

                int count = 0;

                foreach (CustomAttribute attribute in node.Attributes)
                {
                    if (attribute.TargetSelector == selector && attribute.GetResolvedType().Equals(attributeType))
                        count++;
                }

                return count;
            }
예제 #18
0
            public void Analyze(CustomAttributes/*!*/node, Analyzer/*!*/ analyzer, IPhpCustomAttributeProvider/*!*/ target)
            {
                if (node.Attributes == null) return;

                bool duplicate_found = false;

                foreach (CustomAttribute attribute in node.Attributes)
                    attribute.Analyze(analyzer, target, ref duplicate_found);
            }
예제 #19
0
            public void AnalyzeMembers(CustomAttributes/*!*/node, Analyzer/*!*/ analyzer, Scope referringScope)
            {
                if (node.Attributes == null) return;

                foreach (CustomAttribute attribute in node.Attributes)
                    attribute.AnalyzeMembers(analyzer, referringScope);
            }