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); } } } } } }
protected TypeReference CreateBoundTypeReference(ITypeBinding binding) { TypeReference typeReference = new TypeReference(binding.FullName); BindingManager.Bind(typeReference, BindingManager.ToTypeReference(binding)); return(typeReference); }
private void UpdateTypeBinding(string typeName, ITypeBinding typeBinding) { if (typeBinding != null) { _typeBindings[typeName] = typeBinding; AddNativeTypeBinding(typeBinding.Type, typeName); } }
public void RegisterType(INamedType namedType, ITypeBinding typeBinding = null) { if (namedType == null) { throw new ArgumentNullException(nameof(namedType)); } _schemaContext.Types.RegisterType(namedType, typeBinding); }
public ITypeBinding ToTypeBinding(TypeDefinition typeDefinition) { ITypeBinding binding = (ITypeBinding)_bindingCache[typeDefinition]; if (null == binding) { Cache(typeDefinition, binding = new InternalTypeBinding(this, typeDefinition)); } return(binding); }
public bool IsAssignableFrom(ITypeBinding other) { ExternalTypeBinding external = other as ExternalTypeBinding; if (null == external) { return(other.IsSubclassOf(this)); } return(_type.IsAssignableFrom(external._type)); }
public bool IsSubclassOf(ITypeBinding other) { ExternalTypeBinding external = other as ExternalTypeBinding; if (null == external) { throw new NotImplementedException(other.ToString()); } return(_type.IsSubclassOf(external._type)); }
public ITypedBinding ToTypeReference(ITypeBinding type) { ITypedBinding cached = (ITypedBinding)_referenceCache[type]; if (null == cached) { cached = new TypeReferenceBinding(type); _referenceCache[type] = cached; } return(cached); }
public override bool IsSubclassOf(ITypeBinding type) { foreach (TypeReference baseTypeReference in _typeDefinition.BaseTypes) { ITypeBinding baseType = _bindingManager.GetBoundType(baseTypeReference); if (type == baseType || baseType.IsSubclassOf(type)) { return(true); } } return(false); }
public void RegisterType(INamedType namedType, ITypeBinding typeBinding) { if (namedType == null) { throw new ArgumentNullException(nameof(namedType)); } if (!_sealed) { TryUpdateNamedType(namedType); UpdateTypeBinding(namedType.Name, typeBinding); } }
public void RegisterType(INamedType namedType, ITypeBinding typeBinding = null) { if (namedType == null) { throw new ArgumentNullException(nameof(namedType)); } if (!_namedTypes.ContainsKey(namedType.Name)) { _namedTypes[namedType.Name] = namedType; } if (typeBinding != null) { _typeBindings[namedType.Name] = typeBinding; } }
public override void Run() { _astAttributeBaseClass = BindingManager.ToTypeBinding(typeof(AstAttribute)); _systemAttributeBaseClass = BindingManager.ToTypeBinding(typeof(System.Attribute)); int step = 0; while (step < CompilerParameters.MaxAttributeSteps) { Switch(CompileUnit); if (0 == _tasks.Count) { // Colocar informao de tracing aqui... break; } _tasks.Flush(); ++step; } }
public ParameterBinding(ParameterDeclaration parameter, ITypeBinding type) { _parameter = parameter; _type = type; _index = -1; }
bool IsSystemAttribute(ITypeBinding type) { return(type.IsSubclassOf(_systemAttributeBaseClass)); }
/// <summary> /// Scan properties and add column definition. /// </summary> private void AddColumns() { List <string> primaryKeyProps = null; Dictionary <Type, List <IDbColumnBinding> > foreignKeyFields = null; List <string> uniqueKeyProps = null; columns = new TypeBinding <IDbColumnBinding, DbColumnAttribute>(TemplateType, (p, a) => DbColumnBinding.CreateInstance(Setup, p, a, this)); foreach (var col in columns.BindingList) { var keyConstraint = col.KeyConstraint; if (keyConstraint == DbKeyConstraint.PrimaryKey || keyConstraint == DbKeyConstraint.PrimaryForeignKey) { (primaryKeyProps = primaryKeyProps ?? new List <string>()).Add(col.PropertyName); } if (keyConstraint == DbKeyConstraint.UniqueKey) { (uniqueKeyProps = uniqueKeyProps ?? new List <string>()).Add(col.PropertyName); } if (keyConstraint == DbKeyConstraint.ForeignKey || keyConstraint == DbKeyConstraint.PrimaryForeignKey) { foreignKeyFields = foreignKeyFields ?? new Dictionary <Type, List <IDbColumnBinding> >(); if (!foreignKeyFields.TryGetValue(col.PrimaryTableTemplate, out List <IDbColumnBinding> list)) { list = new List <IDbColumnBinding>(); foreignKeyFields.Add(col.PrimaryTableTemplate, list); } list.Add(col); } } if (primaryKeyProps != null) { if (PrimaryKey != null) { throw new ArgumentException($"Multiple primary key definition in table [{TableName}]"); } PrimaryKey = new DbTablePrimaryKeyAttribute(primaryKeyProps.ToArray()); } if (PrimaryKey?.PropertyNames.Length == 1) { SingleColumnPrimaryKey = this.FindColumn(primaryKeyProps[0]); } if (uniqueKeyProps != null) { uniqueKeys.Add(new DbTableUniqueKeyAttribute(uniqueKeyProps.ToArray())); } if (uniqueKeys?.Count == 1 && uniqueKeys[0].PropertyNames.Length == 1) { SingleColumnUniqueKey = this.FindColumn(uniqueKeys[0].PropertyNames[0]); } if (foreignKeyFields != null) { foreach (var item in foreignKeyFields) { foreach (var rel in item.Value) { var attr = new DbTableForeignKeyAttribute(item.Key, rel.PropertyName); foreignKeys.Add(attr); } } } }
bool IsAstAttribute(ITypeBinding type) { return(type.IsSubclassOf(_astAttributeBaseClass)); }
void Cache(object key, ITypeBinding binding) { _bindingCache[key] = binding; }
public virtual bool IsSubclassOf(ITypeBinding other) { return(false); }
public virtual bool IsAssignableFrom(ITypeBinding other) { return(false); }
public LocalBinding(Local local, ITypeBinding typeInfo) { _local = local; _typeInfo = typeInfo; }
// From class Starcounter.Db. Added CultureInfo.InvariantCulture and NumberFormatInfo.InvariantInfo. internal static String CreateObjectString(ITypeBinding typeBind, IObjectView currentObj) { IPropertyBinding propBind = null; String result = FieldSeparator; for (Int32 i = 0; i < typeBind.PropertyCount; i++) { propBind = typeBind.GetPropertyBinding(i); switch (propBind.TypeCode) { case DbTypeCode.Binary: Nullable<Binary> binValue = currentObj.GetBinary(i); if (binValue == null) result += Db.NullString; else result += BinaryToHex(binValue.Value); break; case DbTypeCode.Boolean: Nullable<Boolean> blnValue = currentObj.GetBoolean(i); if (blnValue == null) result += Db.NullString; else result += blnValue.Value.ToString(); break; case DbTypeCode.Byte: Nullable<Byte> byteValue = currentObj.GetByte(i); if (byteValue == null) result += Db.NullString; else result += byteValue.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.DateTime: Nullable<DateTime> dtmValue = currentObj.GetDateTime(i); if (dtmValue == null) result += Db.NullString; else result += dtmValue.Value.ToString("u", DateTimeFormatInfo.InvariantInfo); break; case DbTypeCode.Decimal: Nullable<Decimal> decValue = currentObj.GetDecimal(i); if (decValue == null) result += Db.NullString; else result += decValue.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Double: Nullable<Double> dblValue = currentObj.GetDouble(i); if (dblValue == null) result += Db.NullString; else result += dblValue.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Int16: Nullable<Int16> int16Value = currentObj.GetInt16(i); if (int16Value == null) result += Db.NullString; else result += int16Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Int32: Nullable<Int32> int32Value = currentObj.GetInt32(i); if (int32Value == null) result += Db.NullString; else result += int32Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Int64: Nullable<Int64> int64Value = currentObj.GetInt64(i); if (int64Value == null) result += Db.NullString; else result += int64Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Object: IObjectView objValue = currentObj.GetObject(i); if (objValue == null) result += Db.NullString; else { if (objValue is IObjectProxy) //result += DbHelper.GetObjectID(objValue as Entity).ToString(); result += Utilities.GetObjectIdString(objValue); else result += objValue.ToString(); } break; case DbTypeCode.SByte: Nullable<SByte> sbyteValue = currentObj.GetSByte(i); if (sbyteValue == null) result += Db.NullString; else result += sbyteValue.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.Single: Nullable<Single> sngValue = currentObj.GetSingle(i); if (sngValue == null) result += Db.NullString; else result += sngValue.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.String: String strValue = currentObj.GetString(i); if (strValue == null) result += Db.NullString; else result += strValue; break; case DbTypeCode.UInt16: Nullable<UInt16> uint16Value = currentObj.GetUInt16(i); if (uint16Value == null) result += Db.NullString; else result += uint16Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.UInt32: Nullable<UInt32> uint32Value = currentObj.GetUInt32(i); if (uint32Value == null) result += Db.NullString; else result += uint32Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; case DbTypeCode.UInt64: Nullable<UInt64> uint64Value = currentObj.GetUInt64(i); if (uint64Value == null) result += Db.NullString.ToString(NumberFormatInfo.InvariantInfo); else result += uint64Value.Value.ToString(NumberFormatInfo.InvariantInfo); break; default: throw new Exception("Incorrect TypeCode: " + propBind.TypeCode); } result += FieldSeparator; } return result; }
public TypeReferenceBinding(ITypeBinding type) { _type = type; }