public AddToContext ( |
||
context | Context of |
|
mask | TypeRefMask | Type mask representing types in |
return | TypeRefMask |
/// <summary> /// Gets type mask at target type context representing given type names from given routine. /// </summary> public static TypeRefMask GetTypeMask(TypeRefContext /*!*/ targetCtx, TypeRefContext /*!*/ ctx, string[] tnames, bool fullyQualified = false) { Contract.ThrowIfNull(targetCtx); Contract.ThrowIfNull(ctx); var mask = GetTypeMask(ctx, tnames, fullyQualified); return(targetCtx.AddToContext(ctx, mask)); }
public ITypeRef Transfer(TypeRefContext source, TypeRefContext target) { if (source == target || _returnType.IsVoid || _returnType.IsAnyType) { return(this); } // note: there should be no circular dependency return(new LambdaTypeRef(target.AddToContext(source, _returnType), _signature)); }
/// <summary> /// Gets actual lates static bind type (type of <c>static</c>) if provided. /// Otherwise <c>void</c>. /// </summary> /// <param name="ctx">Target type context.</param> /// <returns>TYpe mask of <c>static</c> in given context or <c>void</c>.</returns> public TypeRefMask GetLateStaticBindType(TypeRefContext /*!*/ ctx) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (_typeCtx != null && !_lateStaticBindType.IsUninitialized) { return(ctx.AddToContext(_typeCtx, _lateStaticBindType)); } return(0); }
/// <summary> /// Gets actual parameter type if provided. Otherwise <c>void</c>. /// </summary> /// <param name="ctx">Target type context.</param> /// <param name="index">Index of parameter.</param> /// <returns>Type mask of the parameter or <c>void</c>.</returns> public TypeRefMask GetParamType(TypeRefContext /*!*/ ctx, int index) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (_typeCtx != null && index >= 0 && index < _paramsType.Length) { return(ctx.AddToContext(_typeCtx, _paramsType[index])); } return(0); }
/// <summary> /// Gets expected return type mask of given symbol (field, function, method or property). /// </summary> /// <remarks>Returned type mask corresponds to types that can be returned by invoking given symbol.</remarks> public static TypeRefMask GetResultType(this IPhpValue symbol, TypeRefContext ctx) { Contract.ThrowIfNull(symbol); Contract.ThrowIfNull(ctx); TypeSymbol t; if (symbol is FieldSymbol) { t = ((FieldSymbol)symbol).Type; } else if (symbol is MethodSymbol) { var m = (MethodSymbol)symbol; var r = symbol as SourceRoutineSymbol; if (r != null && r.IsStatic) { // In case of a static function, we can return expected return type mask exactly. // Such function cannot be overriden and we know exactly what the return type will be even the CLR type covers more possibilities. return ctx.AddToContext(r.TypeRefContext, r.ResultTypeMask); } t = m.ReturnType; } else if (symbol is PropertySymbol) { t = ((PropertySymbol)symbol).Type; } else if (symbol is ParameterSymbol) { t = ((ParameterSymbol)symbol).Type; } else { throw Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(symbol); } // create the type mask from the CLR type symbol var mask = TypeRefFactory.CreateMask(ctx, t); // [CastToFalse] if (symbol is IPhpRoutineSymbol && ((IPhpRoutineSymbol)symbol).CastToFalse) { mask |= ctx.GetBooleanTypeMask(); // the function may return FALSE } // return mask; }
public ITypeRef /*!*/ Transfer(TypeRefContext /*!*/ source, TypeRefContext /*!*/ target) { Contract.ThrowIfNull(source); Contract.ThrowIfNull(target); // TODO: keys if (source == target || _elementType.IsVoid || _elementType.IsAnyType) { return(this); } // note: there should be no circular dependency return(new ArrayTypeRef(_keys, target.AddToContext(source, _elementType))); }
/// <summary> /// Gets actual lates static bind type (type of <c>static</c>) if provided. /// Otherwise <c>void</c>. /// </summary> /// <param name="ctx">Target type context.</param> /// <returns>TYpe mask of <c>static</c> in given context or <c>void</c>.</returns> public TypeRefMask GetLateStaticBindType(TypeRefContext/*!*/ctx) { if (ctx == null) throw new ArgumentNullException("ctx"); if (_typeCtx != null && !_lateStaticBindType.IsUninitialized) return ctx.AddToContext(_typeCtx, _lateStaticBindType); return 0; }
/// <summary> /// Gets actual parameter type if provided. Otherwise <c>void</c>. /// </summary> /// <param name="ctx">Target type context.</param> /// <param name="index">Index of parameter.</param> /// <returns>Type mask of the parameter or <c>void</c>.</returns> public TypeRefMask GetParamType(TypeRefContext/*!*/ctx, int index) { if (ctx == null) throw new ArgumentNullException("ctx"); if (_typeCtx != null && index >= 0 && index < _paramsType.Length) return ctx.AddToContext(_typeCtx, _paramsType[index]); return 0; }
public static TypeRefMask CreateMask(TypeRefContext ctx, ITypeRef tref) { Contract.ThrowIfNull(tref); TypeRefMask result = 0; result.AddType(ctx.AddToContext(tref)); if (!tref.IsPrimitiveType && !tref.IsArray) { result.IncludesSubclasses = true; } return result; }
/// <summary> /// Gets type mask at target type context representing given type names from given routine. /// </summary> public static TypeRefMask GetTypeMask(TypeRefContext/*!*/targetCtx, TypeRefContext/*!*/ctx, string[] tnames, NamingContext naming, bool fullyQualified = false) { Contract.ThrowIfNull(targetCtx); Contract.ThrowIfNull(ctx); var mask = GetTypeMask(ctx, tnames, naming, fullyQualified); return targetCtx.AddToContext(ctx, mask); }