/// <summary> /// Enqueues initializers of a class fields and constants. /// </summary> void EnqueueFieldsInitializer(SourceTypeSymbol type) { type.GetMembers().OfType <SourceFieldSymbol>().Foreach(f => { if (f.Initializer != null) { EnqueueExpression( f.Initializer, TypeRefFactory.CreateTypeRefContext(type), //the context will be lost, analysis resolves constant values only and types are temporary NameUtils.GetNamingContext(type.Syntax)); } }); }
internal override TypeSymbol GetFieldType(ConsList <FieldSymbol> fieldsBeingBound) { var vartag = _phpdoc?.GetElement <PHPDocBlock.VarTag>(); if (vartag != null && vartag.TypeNamesArray.Length != 0) { var typectx = TypeRefFactory.CreateTypeRefContext(_type); var tmask = PHPDoc.GetTypeMask(typectx, vartag.TypeNamesArray); var t = DeclaringCompilation.GetTypeFromTypeRef(typectx, tmask); return(t); } // TODO: analysed PHP type return(DeclaringCompilation.CoreTypes.PhpValue); }
internal override TypeSymbol GetFieldType(ConsList <FieldSymbol> fieldsBeingBound) { // TODO: HHVM TypeHint // if ((IsConst || IsReadOnly) && Initializer != null) { // resolved type symbol if possible if (Initializer.ResultType != null) { return(Initializer.ResultType); } // resolved value type if possible var cvalue = Initializer.ConstantValue; if (cvalue.HasValue) { var specialType = (cvalue.Value != null) ? cvalue.ToConstantValueOrNull()?.SpecialType : SpecialType.System_Object; // NULL if (specialType.HasValue && specialType != SpecialType.None) { return(DeclaringCompilation.GetSpecialType(specialType.Value)); } } // //return DeclaringCompilation.GetTypeFromTypeRef(typectx, Initializer.TypeRefMask); } // PHPDoc @var type if ((DeclaringCompilation.Options.PhpDocTypes & PhpDocTypes.FieldTypes) != 0) { var vartag = FindPhpDocVarTag(); if (vartag != null && vartag.TypeNamesArray.Length != 0) { var dummyctx = TypeRefFactory.CreateTypeRefContext(_containingType); var tmask = PHPDoc.GetTypeMask(dummyctx, vartag.TypeNamesArray, NameUtils.GetNamingContext(_containingType.Syntax)); return(DeclaringCompilation.GetTypeFromTypeRef(dummyctx, tmask)); } } // default return(DeclaringCompilation.CoreTypes.PhpValue); }
protected override TypeRefContext CreateTypeRefContext() => TypeRefFactory.CreateTypeRefContext(_type);
/// <summary> /// Field's <see cref="TypeRefContext"/> instance. /// </summary> internal TypeRefContext EnsureTypeRefContext() => _typeCtx ?? (_typeCtx = TypeRefFactory.CreateTypeRefContext(_containingType));