Inheritance: Node, INodeWithArguments
Ejemplo n.º 1
0
 public ApplyAttributeTask(CompilerContext context, Boo.Lang.Compiler.Ast.Attribute attribute, Type type)
 {
     _context    = context;
     _attribute  = attribute;
     _type       = type;
     _targetNode = GetTargetNode();
 }
Ejemplo n.º 2
0
        private void WriteAttributes(AttributeCollection attributes)
        {
            IEnumerator <Boo.Lang.Compiler.Ast.Attribute> enumerator = attributes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Boo.Lang.Compiler.Ast.Attribute current = enumerator.Current;
                    Write(Indent());
                    Write("[");
                    Write(current.Name);
                    if (((ICollection)current.Arguments).Count > 0)
                    {
                        WriteParenthesidCommaSeparatedList(current.Arguments);
                    }
                    Write("]");
                    WriteLine();
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Ejemplo n.º 3
0
 override public void LeaveProperty(Property node)
 {
     if (node.Name == "self")
     {
         node.Name = "Item";
     }
     if (node.Name == "Item" && node.Parameters.Count > 0 && !node.IsStatic)
     {
         TypeDefinition t = node.ParentNode as TypeDefinition;
         if (t != null)
         {
             bool already_has_attribute = false;
             foreach (Boo.Lang.Compiler.Ast.Attribute a in t.Attributes)
             {
                 if (a.Name.IndexOf("DefaultMember") >= 0)
                 {
                     already_has_attribute = true;
                     break;
                 }
             }
             if (!already_has_attribute)
             {
                 Boo.Lang.Compiler.Ast.Attribute att = new Boo.Lang.Compiler.Ast.Attribute(t.LexicalInfo);
                 att.Name = Types.DefaultMemberAttribute.FullName;
                 att.Arguments.Add(new StringLiteralExpression(node.Name));
                 t.Attributes.Add(att);
                 Visit(att);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public override void OnAttribute(Attribute node)
        {
            if (_current == null) return;

            //attributes for the merged class contain any and all attributes declared on each partial definition
            _current.Attributes.Add(node);
        }
Ejemplo n.º 5
0
        public Attribute CreateAttribute(IConstructor constructor, Expression arg)
        {
            Attribute attribute = CreateAttribute(constructor);

            attribute.Arguments.Add(arg);
            return(attribute);
        }
Ejemplo n.º 6
0
		private void CheckAttributeUsageCardinality(Attribute node, Type attrType, AttributeUsageAttribute usage)
		{
			if (usage.AllowMultiple)
				return;

			if (HasSiblingAttributesOfSameType(node, attrType))
				MultipleAttributeUsageError(node, attrType);
		}
Ejemplo n.º 7
0
        public Attribute CreateAttribute(IConstructor constructor)
        {
            Attribute attribute = new Attribute();

            attribute.Name   = constructor.DeclaringType.FullName;
            attribute.Entity = constructor;
            return(attribute);
        }
Ejemplo n.º 8
0
 public static CompilerError AttributeApplicationError(Exception error, Boo.Lang.Compiler.Ast.Attribute attribute, Type attributeType)
 {
     return(new CompilerError("BCE0009",
                              attribute.LexicalInfo,
                              error,
                              attributeType,
                              error.Message));
 }
Ejemplo n.º 9
0
 B.Attribute MakeAttribute(string name, params B.Expression[] arguments)
 {
     B.Attribute a = new B.Attribute(lastLexicalInfo, name);
     foreach (B.Expression arg in arguments)
     {
         a.Arguments.Add(arg);
     }
     return(a);
 }
Ejemplo n.º 10
0
        public Attribute CreateAttribute(IConstructor constructor, Expression arg)
        {
            Attribute attribute = new Attribute();

            attribute.Name   = constructor.DeclaringType.FullName;
            attribute.Entity = constructor;
            attribute.Arguments.Add(arg);
            return(attribute);
        }
Ejemplo n.º 11
0
		private void CheckAttributeUsageTarget(Attribute node, Type attrType, AttributeUsageAttribute usage)
		{
			var validAttributeTargets = ValidAttributeTargetsFor(attrType, usage);
			if (validAttributeTargets == AttributeTargets.All)
				return;

			var target = AttributeTargetsFor(node);
			if (target.HasValue && !IsValid(target.Value, validAttributeTargets))
				Errors.Add(CompilerErrorFactory.InvalidAttributeTarget(node, attrType, validAttributeTargets));
		}
Ejemplo n.º 12
0
        override public void OnAttribute(Attribute node)
        {
            if (_current == null)
            {
                return;
            }

            //attributes for the merged class contain any and all attributes declared on each partial definition
            _current.Attributes.Add(node);
        }
Ejemplo n.º 13
0
 private void CheckAttributeParameters(Boo.Lang.Compiler.Ast.Attribute node)
 {
     foreach (Expression e in node.Arguments)
     {
         if (e.NodeType == NodeType.BinaryExpression &&
             ((BinaryExpression)e).Operator == BinaryOperatorType.Assign)
         {
             Error(node, CompilerErrorFactory.ColonInsteadOfEquals(node));
         }
     }
 }
Ejemplo n.º 14
0
        public override void OnAttribute(Attribute node)
        {
            var ctor = node.Entity as IMember;

            if (ctor != null)
            {
                AddAsSeen(ctor.DeclaringType);
            }

            base.OnAttribute(node);
        }
Ejemplo n.º 15
0
        private void CheckAttributeUsageCardinality(Attribute node, Type attrType, AttributeUsageAttribute usage)
        {
            if (usage.AllowMultiple)
            {
                return;
            }

            if (HasSiblingAttributesOfSameType(node, attrType))
            {
                MultipleAttributeUsageError(node, attrType);
            }
        }
Ejemplo n.º 16
0
		override public void OnAttribute(Attribute node)
		{
			var attrType = AttributeType(node);
			if (attrType == null)
				return;

			var usage = AttributeUsageFor(attrType);
			if (usage == null)
				return;

			CheckAttributeUsage(node, attrType, usage);
		}
        private void processModule(Module module) {
            var key = module.LexicalInfo.FileName;
            var source = sources.FirstOrDefault(x => x.Key == key);
            if (null == source) return;
            var type = module.Members[0] as ClassDefinition;
            type.Name = source.Key.Replace("/","_0_");
            module.Namespace = null;
            var attr = new Attribute();
            attr.Name = typeof (TimeStampAttribute).Name;
            attr.Arguments.Add(new StringLiteralExpression(source.LastModified.ToString("dd.MM.yyyy HH:mm:ss")));
            type.Attributes.Add(attr);

        }
Ejemplo n.º 18
0
        override public void OnAttribute(Boo.Lang.Compiler.Ast.Attribute node)
        {
            Type attrType = AttributeType(node);

            if (attrType == null)
            {
                return;
            }

            // check allowed attribute usage(s)
            System.Attribute[] usages = System.Attribute.GetCustomAttributes(attrType, typeof(AttributeUsageAttribute));
            if (usages.Length == 0)
            {
                return;
            }

            //only one AttributeUsage is allowed anyway
            AttributeUsageAttribute usage = (AttributeUsageAttribute)usages[0];

            if (AttributeTargets.All != usage.ValidOn)
            {
                AttributeTargets?target = TargetFor(node);
                if (target.HasValue && !IsValid(usage, target.Value))
                {
                    Errors.Add(
                        CompilerErrorFactory.InvalidAttributeTarget(node, attrType, usage.ValidOn));
                }
            }
            if (!usage.AllowMultiple)
            {
                INodeWithAttributes m = node.ParentNode as INodeWithAttributes;
                foreach (Boo.Lang.Compiler.Ast.Attribute mAttr in m.Attributes)
                {
                    if (mAttr == node)
                    {
                        continue;
                    }
                    IExternalEntity mAttrEnt = mAttr.Entity as IExternalEntity;
                    if (null != mAttrEnt && mAttrEnt.MemberInfo.DeclaringType == attrType)
                    {
                        Errors.Add(
                            CompilerErrorFactory.MultipleAttributeUsage(node, attrType));
                    }
                }
            }

            // handle special compiler-supported attributes
            //TODO: ObsoleteAttribute
        }
Ejemplo n.º 19
0
 public object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute a, object data)
 {
     B.Attribute att = new B.Attribute(GetLexicalInfo(a), a.Name);
     att.EndSourceLocation = GetLocation(a.EndLocation);
     ConvertExpressions(a.PositionalArguments, att.Arguments);
     foreach (NamedArgumentExpression nae in a.NamedArguments)
     {
         B.Expression expr = ConvertExpression(nae.Expression);
         if (expr != null)
         {
             att.NamedArguments.Add(new B.ExpressionPair(new B.ReferenceExpression(nae.Name), expr));
         }
     }
     return(att);
 }
Ejemplo n.º 20
0
        private void CheckAttributeUsageTarget(Attribute node, Type attrType, AttributeUsageAttribute usage)
        {
            var validAttributeTargets = ValidAttributeTargetsFor(attrType, usage);

            if (validAttributeTargets == AttributeTargets.All)
            {
                return;
            }

            var target = AttributeTargetsFor(node);

            if (target.HasValue && !IsValid(target.Value, validAttributeTargets))
            {
                Errors.Add(CompilerErrorFactory.InvalidAttributeTarget(node, attrType, validAttributeTargets));
            }
        }
Ejemplo n.º 21
0
        override public void OnAttribute(Attribute node)
        {
            var attrType = AttributeType(node);

            if (attrType == null)
            {
                return;
            }

            var usage = AttributeUsageFor(attrType);

            if (usage == null)
            {
                return;
            }

            CheckAttributeUsage(node, attrType, usage);
        }
Ejemplo n.º 22
0
 static public Boo.Lang.Compiler.Ast.Attribute ConvertExpressionToAttribute(
     Expression item)
 {
     Boo.Lang.Compiler.Ast.Attribute att =
         new Boo.Lang.Compiler.Ast.Attribute(item.LexicalInfo);
     if (item is MethodInvocationExpression)
     {
         MethodInvocationExpression m = (MethodInvocationExpression)item;
         att.Name           = m.Target.ToString();
         att.Arguments      = m.Arguments;
         att.NamedArguments = m.NamedArguments;
     }
     else
     {
         att.Name = item.ToString();
     }
     return(att);
 }
Ejemplo n.º 23
0
		private void tryClass(Node targetNode) {
			var cls = targetNode as ClassDefinition;
			if (cls == null)
			{
				return;
			}
			if (cls.BaseTypes.Count == 0)
			{
				cls.BaseTypes.Insert(0, new SimpleTypeReference("Comdiv.Framework.Quick.QuickBase"));
			}
			var attr = new Attribute("Comdiv.Framework.Quick.actionAttribute");
			attr.Arguments.Add(new StringLiteralExpression(cls.Name.Replace("_", ".")));
			cls.Attributes.Add(attr);

			var body = targetNode.GetEnclosingModule()["regmethod"] as Block;
			var registrycall = new SlicingExpression(new ReferenceExpression("registry"), new StringLiteralExpression(cls.Name.Replace("_", ".") + ".quick"));
			var assign = new ReferenceExpression(cls.Name);
			var aexpr = new BinaryExpression(BinaryOperatorType.Assign, registrycall, assign);
			body.Add(aexpr);
		}
Ejemplo n.º 24
0
 private void VisitAttributes(IEnumerable <Boo.Lang.Compiler.Ast.Attribute> attrs, CodeAttributeDeclarationCollection coll)
 {
     if (attrs != null)
     {
         IEnumerator <Boo.Lang.Compiler.Ast.Attribute> enumerator = attrs.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 Boo.Lang.Compiler.Ast.Attribute current = enumerator.Current;
                 CodeAttributeDeclaration        codeAttributeDeclaration = new CodeAttributeDeclaration(current.Name, current.Arguments.Select(this.VisitAttributesClosure3).ToArray());
                 codeAttributeDeclaration.Arguments.AddRange(current.NamedArguments.Select(this.VisitAttributesClosure4).ToArray());
                 coll.Add(codeAttributeDeclaration);
             }
         }
         finally
         {
             enumerator.Dispose();
         }
     }
 }
Ejemplo n.º 25
0
        private static AttributeTargets?AttributeTargetsFor(Attribute node)
        {
            var parentNode = node.ParentNode as Method;

            if (parentNode != null)
            {
                var returnTypeAttributes = (parentNode).ReturnTypeAttributes;
                if (returnTypeAttributes.Contains(node))
                {
                    return(AttributeTargets.ReturnValue);
                }
            }

            AttributeTargets target;

            if (NodeUsageTargets().TryGetValue(node.ParentNode.GetType(), out target))
            {
                return(target);
            }

            return(null);
        }
Ejemplo n.º 26
0
		private static IEnumerable<Attribute> SiblingAttributesOfSameType(Attribute node, Type attrType)
		{
			var attributeContainer = ((INodeWithAttributes) node.ParentNode);
			return attributeContainer.Attributes.Where(_ => _ != node && IsAttributeOfType(attrType, _));
		}
Ejemplo n.º 27
0
		override public object Clone()
		{
		
			Attribute clone = new Attribute();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._name = _name;
			if (null != _arguments)
			{
				clone._arguments = _arguments.Clone() as ExpressionCollection;
				clone._arguments.InitializeParent(clone);
			}
			if (null != _namedArguments)
			{
				clone._namedArguments = _namedArguments.Clone() as ExpressionPairCollection;
				clone._namedArguments.InitializeParent(clone);
			}
			return clone;


		}
Ejemplo n.º 28
0
		private void CheckAttributeUsage(Attribute node, Type attrType, AttributeUsageAttribute usage)
		{
			CheckAttributeUsageTarget(node, attrType, usage);
			CheckAttributeUsageCardinality(node, attrType, usage);
		}
Ejemplo n.º 29
0
		private static Type AttributeType(Attribute node)
		{
			var attr = node.Entity as IExternalEntity;
			return attr == null ? null : attr.MemberInfo.DeclaringType;
		}
Ejemplo n.º 30
0
		private static bool IsAttributeOfType(Type attrType, Attribute attribute)
		{
			var entity = attribute.Entity as IExternalEntity;
			return entity != null && entity.MemberInfo.DeclaringType == attrType;
		}
Ejemplo n.º 31
0
 private static bool HasSiblingAttributesOfSameType(Attribute node, Type attrType)
 {
     return(SiblingAttributesOfSameType(node, attrType).Any());
 }
Ejemplo n.º 32
0
 public MappedAttribute(CompileResults results, Attribute node)
     : base(results, node, node.Name.Length)
 {
 }
Ejemplo n.º 33
0
 public Attribute CreateAttribute(IConstructor constructor)
 {
     Attribute attribute = new Attribute();
     attribute.Name = constructor.DeclaringType.FullName;
     attribute.Entity = constructor;
     return attribute;
 }
Ejemplo n.º 34
0
 private void MultipleAttributeUsageError(Attribute attribute, Type attrType)
 {
     Errors.Add(CompilerErrorFactory.MultipleAttributeUsage(attribute, attrType));
 }
Ejemplo n.º 35
0
        private static bool IsAttributeOfType(Type attrType, Attribute attribute)
        {
            var entity = attribute.Entity as IExternalEntity;

            return(entity != null && entity.MemberInfo.DeclaringType == attrType);
        }
Ejemplo n.º 36
0
        private static Type AttributeType(Attribute node)
        {
            var attr = node.Entity as IExternalEntity;

            return(attr == null ? null : attr.MemberInfo.DeclaringType);
        }
Ejemplo n.º 37
0
 public ApplyAttributeTask(CompilerContext context, Boo.Lang.Compiler.Ast.Attribute attribute, Type type)
 {
     _context = context;
     _attribute = attribute;
     _type = type;
     _targetNode = GetTargetNode();
 }
Ejemplo n.º 38
0
        CustomAttributeBuilder GetCustomAttributeBuilder(Attribute node)
        {
            IConstructor constructor = (IConstructor)GetEntity(node);
            ConstructorInfo constructorInfo = GetConstructorInfo(constructor);
            object[] constructorArgs = GetValues(constructor.GetParameters(),
                                                 node.Arguments);

            ExpressionPairCollection namedArgs = node.NamedArguments;
            if (namedArgs.Count > 0)
            {
                PropertyInfo[] namedProperties;
                object[] propertyValues;
                FieldInfo[] namedFields;
                object[] fieldValues;
                GetNamedValues(namedArgs,
                               out namedProperties, out propertyValues,
                               out namedFields, out fieldValues);
                return new CustomAttributeBuilder(
                    constructorInfo, constructorArgs,
                    namedProperties, propertyValues,
                    namedFields, fieldValues);
            }
            return new CustomAttributeBuilder(constructorInfo, constructorArgs);
        }
Ejemplo n.º 39
0
 public override void LeaveAttribute(Attribute node)
 {
     CheckName(node,node.Name);
 }
Ejemplo n.º 40
0
 public override void OnAttribute(Boo.Lang.Compiler.Ast.Attribute node)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 41
0
 private void CheckAttributeUsage(Attribute node, Type attrType, AttributeUsageAttribute usage)
 {
     CheckAttributeUsageTarget(node, attrType, usage);
     CheckAttributeUsageCardinality(node, attrType, usage);
 }
Ejemplo n.º 42
0
		public object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute a, object data)
		{
			B.Attribute att = new B.Attribute(GetLexicalInfo(a), a.Name);
			att.EndSourceLocation = GetLocation(a.EndLocation);
			ConvertExpressions(a.PositionalArguments, att.Arguments);
			foreach (NamedArgumentExpression nae in a.NamedArguments) {
				B.Expression expr = ConvertExpression(nae.Expression);
				if (expr != null) {
					att.NamedArguments.Add(new B.ExpressionPair(new B.ReferenceExpression(nae.Name), expr));
				}
			}
			return att;
		}
Ejemplo n.º 43
0
		private void MultipleAttributeUsageError(Attribute attribute, Type attrType)
		{
			Errors.Add(CompilerErrorFactory.MultipleAttributeUsage(attribute, attrType));
		}
Ejemplo n.º 44
0
 public void AddAttribute(Attribute attribute)
 {
     _cd.Attributes.Add(attribute);
 }
Ejemplo n.º 45
0
		private static AttributeTargets? AttributeTargetsFor(Attribute node)
		{
			var parentNode = node.ParentNode as Method;
			if (parentNode != null)
			{
				var returnTypeAttributes = (parentNode).ReturnTypeAttributes;
				if (returnTypeAttributes.Contains(node))
					return AttributeTargets.ReturnValue;
			}

			AttributeTargets target;
			if (NodeUsageTargets().TryGetValue(node.ParentNode.GetType(), out target))
				return target;

			return null;
		}
Ejemplo n.º 46
0
			public void CreateAttributeTypes(Attribute attr)
			{
				AppDomain domain = Thread.GetDomain();
				try
				{
					domain.TypeResolve += OnTypeResolve;
					foreach (var arg in attr.Arguments)
						if (arg.ExpressionType != null)
							this.EnsureInternalDependencies(arg.ExpressionType);
					foreach (var arg in attr.NamedArguments)
						if (arg.Second.ExpressionType != null)
							this.EnsureInternalDependencies(arg.Second.ExpressionType);
				}
				finally
				{
					domain.TypeResolve -= OnTypeResolve;
				}				
			}
Ejemplo n.º 47
0
 Boo.Lang.Compiler.Ast.Attribute CreateBooModuleAttribute()
 {
     Boo.Lang.Compiler.Ast.Attribute attribute = new Boo.Lang.Compiler.Ast.Attribute(ModuleAttributeName);
     attribute.Entity = _booModuleAttributeType;
     return(attribute);
 }
Ejemplo n.º 48
0
		CustomAttributeBuilder GetCustomAttributeBuilder(Attribute node)
		{
			var constructor = (IConstructor)GetEntity(node);
			var constructorInfo = GetConstructorInfo(constructor);
			object[] constructorArgs = ArgumentsForAttributeConstructor(constructor, node.Arguments);

			var namedArgs = node.NamedArguments;
			if (namedArgs.Count > 0)
			{
				PropertyInfo[] namedProperties;
				object[] propertyValues;
				FieldInfo[] namedFields;
				object[] fieldValues;
				GetNamedValues(namedArgs,
							   out namedProperties,
							   out propertyValues,
							   out namedFields,
							   out fieldValues);
				return new CustomAttributeBuilder(
					constructorInfo, constructorArgs,
					namedProperties, propertyValues,
					namedFields, fieldValues);
			}
			return new CustomAttributeBuilder(constructorInfo, constructorArgs);
		}
Ejemplo n.º 49
0
 void ScheduleAttributeApplication(Boo.Lang.Compiler.Ast.Attribute attribute, Type type)
 {
     _tasks.Add(new ApplyAttributeTask(_context, attribute, type));
 }
Ejemplo n.º 50
0
        //throws RecognitionException, TokenStreamException
        protected void assembly_attribute(
            Module module
            )
        {
            antlr.IToken id = null;
                Boo.Lang.Compiler.Ast.Attribute attr = null;

            try {      // for error handling
            match(ASSEMBLY_ATTRIBUTE_BEGIN);
            id=identifier();
            if (0==inputState.guessing)
            {
                attr = new Boo.Lang.Compiler.Ast.Attribute(ToLexicalInfo(id), id.getText());
            }
            {
                switch ( LA(1) )
                {
                case LPAREN:
                {
                    match(LPAREN);
                    argument_list(attr);
                    match(RPAREN);
                    break;
                }
                case RBRACK:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            match(RBRACK);
            if (0==inputState.guessing)
            {
                module.AssemblyAttributes.Add(attr);
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_18_);
            }
            else
            {
                throw ex;
            }
            }
        }
Ejemplo n.º 51
0
		private static bool HasSiblingAttributesOfSameType(Attribute node, Type attrType)
		{
			return SiblingAttributesOfSameType(node, attrType).Any();
		}
Ejemplo n.º 52
0
        private static IEnumerable <Attribute> SiblingAttributesOfSameType(Attribute node, Type attrType)
        {
            var attributeContainer = ((INodeWithAttributes)node.ParentNode);

            return(attributeContainer.Attributes.Where(_ => _ != node && IsAttributeOfType(attrType, _)));
        }
Ejemplo n.º 53
0
 public override void OnAttribute(Attribute node)
 {
 }
Ejemplo n.º 54
0
 Boo.Lang.Compiler.Ast.Attribute CreateBooModuleAttribute()
 {
     Boo.Lang.Compiler.Ast.Attribute attribute = new Boo.Lang.Compiler.Ast.Attribute(ModuleAttributeName);
     attribute.Entity = _booModuleAttributeType;
     return attribute;
 }
Ejemplo n.º 55
0
	protected AstAttribute  attribute() //throws RecognitionException, TokenStreamException
{
		AstAttribute attr;
		
		IToken  t = null;
				
				antlr.IToken id = null;
		attr = null;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case THEN:
				case ID:
				{
					id=identifier();
					break;
				}
				case TRANSIENT:
				{
					t = LT(1);
					match(TRANSIENT);
					if (0==inputState.guessing)
					{
						id=t;
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						attr = new AstAttribute(ToLexicalInfo(id), id.getText());
					
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					match(LPAREN);
					argument_list(attr);
					match(RPAREN);
					break;
				}
				case RBRACK:
				case COMMA:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "attribute");
				recover(ex,tokenSet_52_);
			}
			else
			{
				throw ex;
			}
		}
		return attr;
	}
Ejemplo n.º 56
0
 public static CompilerError AttributeApplicationError(Exception error, Ast.Attribute attribute, Type attributeType)
 {
     return(Instantiate("BCE0009", attribute, error, attributeType, error.Message));
 }
Ejemplo n.º 57
0
        public override void OnAttribute(Attribute node)
        {
            var tag = node.Entity as IType;
            if (null != tag && !IsError(tag))
            {
                Visit(node.Arguments);
                ResolveNamedArguments(tag, node.NamedArguments);

                IConstructor constructor = GetCorrectConstructor(node, tag, node.Arguments);
                if (null != constructor)
                {
                    Bind(node, constructor);
                }
            }
        }
Ejemplo n.º 58
0
        //throws RecognitionException, TokenStreamException
        protected void attribute()
        {
            antlr.IToken id = null;
                Boo.Lang.Compiler.Ast.Attribute attr = null;

            try {      // for error handling
            id=identifier();
            if (0==inputState.guessing)
            {

                        attr = new Boo.Lang.Compiler.Ast.Attribute(SourceLocationFactory.ToLexicalInfo(id), id.getText());
                        _attributes.Add(attr);

            }
            {
                switch ( LA(1) )
                {
                case LPAREN:
                {
                    match(LPAREN);
                    argument_list(attr);
                    match(RPAREN);
                    break;
                }
                case RBRACK:
                case COMMA:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_46_);
            }
            else
            {
                throw ex;
            }
            }
        }
Ejemplo n.º 59
0
 public void AddAttribute(Attribute attribute)
 {
     _cd.Attributes.Add(attribute);
 }
Ejemplo n.º 60
0
		B.Attribute MakeAttribute(string name, params B.Expression[] arguments)
		{
			B.Attribute a = new B.Attribute(lastLexicalInfo, name);
			foreach (B.Expression arg in arguments) {
				a.Arguments.Add(arg);
			}
			return a;
		}