コード例 #1
0
ファイル: AstAttributesStep.cs プロジェクト: codehaus/boo
        public override void OnAttribute(Boo.Lang.Ast.Attribute attribute, ref Boo.Lang.Ast.Attribute resultingNode)
        {
            // Neste primeiro passo tentamos apenas
            // resolver ast attributes.
            // Um passo posterior (resoluo de nomes e tipos) ir
            // assegurar que todos os nomes tenham sido resolvidos e colocar
            // mensagens de erro de acordo
            IBinding binding = ResolveQualifiedName(attribute, attribute.Name);

            if (null == binding)
            {
                binding = ResolveQualifiedName(attribute, BuildAttributeName(attribute.Name));
            }

            if (null != binding)
            {
                if (BindingType.Ambiguous == binding.BindingType)
                {
                    Errors.AmbiguousName(attribute, attribute.Name, ((AmbiguousBinding)binding).Bindings);
                }
                else
                {
                    if (BindingType.TypeReference != binding.BindingType)
                    {
                        Errors.NameNotType(attribute, attribute.Name);
                    }
                    else
                    {
                        ITypeBinding attributeType = ((ITypedBinding)binding).BoundType;
                        if (IsAstAttribute(attributeType))
                        {
                            ExternalTypeBinding externalType = attributeType as ExternalTypeBinding;
                            if (null == externalType)
                            {
                                Errors.AstAttributeMustBeExternal(attribute, attributeType);
                            }
                            else
                            {
                                ScheduleAttributeApplication(attribute, externalType.Type);

                                // remove it from parent
                                resultingNode = null;
                            }
                        }
                        else
                        {
                            if (!IsSystemAttribute(attributeType))
                            {
                                Errors.TypeNotAttribute(attribute, attributeType.FullName);
                            }
                            else
                            {
                                // remember the attribute's type
                                BindingManager.Bind(attribute, attributeType);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public void AstAttributeMustBeExternal(Boo.Lang.Ast.Attribute attribute, Bindings.ITypeBinding resolvedType)
 {
     Add(new Error(attribute, Format("AstAttributeMustBeExternal", resolvedType.FullName)));
 }
コード例 #3
0
        public void AttributeResolution(Boo.Lang.Ast.Attribute attribute, Type type, Exception cause)
        {
            string msg = Format("AttributeResolution", type, cause.Message);

            Add(new Error(attribute, msg, cause));
        }
コード例 #4
0
ファイル: AstAttributesStep.cs プロジェクト: codehaus/boo
 public ApplyAttributeTask(CompilerContext context, Boo.Lang.Ast.Attribute attribute, Type type)
 {
     _context   = context;
     _attribute = attribute;
     _type      = type;
 }
コード例 #5
0
ファイル: AstAttributesStep.cs プロジェクト: codehaus/boo
 void ScheduleAttributeApplication(Boo.Lang.Ast.Attribute attribute, Type type)
 {
     _tasks.Add(new ApplyAttributeTask(_context, attribute, type));
 }