public void TestGetByName() { // positive tests foreach (var name in new[] { QualifiedName.Boolean, QualifiedName.Integer, QualifiedName.LongInteger, QualifiedName.Double, QualifiedName.String, QualifiedName.Resource, QualifiedName.Array, QualifiedName.Object, QualifiedName.Callable }) { Assert.IsTrue(name.IsPrimitiveTypeName); Assert.IsNotNull(PrimitiveType.GetByName(name)); Assert.IsNotNull(PrimitiveType.GetByName(new PrimitiveTypeName(name))); } // false tests foreach (var name in new[] { QualifiedName.Error, QualifiedName.False, QualifiedName.Global, QualifiedName.Lambda, QualifiedName.Null, QualifiedName.True }) { Assert.IsFalse(name.IsPrimitiveTypeName); Assert.IsNull(PrimitiveType.GetByName(name)); } }
internal override bool Analyze(PrimitiveTypeRef node, Analyzer analyzer) { Debug.Assert(node.QualifiedName.IsPrimitiveTypeName); type = PrimitiveType.GetByName(node.QualifiedName); if (type == null) { throw new InvalidOperationException(); } // return(true); }
private static object[] GetStubParameterTypes( int paramCount, int typeParamCount, PhpRoutineSignature /*!*/ signature, PHP.Core.AST.FormalTypeParam[] /*!*/ formalTypeParams) { object[] parameter_types = new object[paramCount]; for (int i = 0; i < paramCount; i++) { DType type_hint = signature.TypeHints[i]; if (type_hint != null && !type_hint.IsUnknown) { GenericParameter gen_type_hint = type_hint as GenericParameter; if (gen_type_hint != null) { // this is a generic parameter - declared by either the method or type if (gen_type_hint.DeclaringMember is PhpRoutine) { if (gen_type_hint.Index < typeParamCount) { // unknown at this point - fixed-up later parameter_types[i] = gen_type_hint.Index; } else { // default generic parameter var typeparam = formalTypeParams[gen_type_hint.Index].DefaultType; DType default_type = typeparam as DType; if (default_type == null && typeparam is GenericQualifiedName) { default_type = PrimitiveType.GetByName((GenericQualifiedName)typeparam); } parameter_types[i] = (default_type == null ? Types.Object[0] : default_type.RealType); } } else { parameter_types[i] = gen_type_hint.RealGenericTypeParameterBuilder; } } else { parameter_types[i] = type_hint.RealType; } } else { parameter_types[i] = Types.Object[0]; } // make it byref if declared with & if (signature.AliasMask[i]) { Type type = parameter_types[i] as Type; if (type != null) { parameter_types[i] = type.MakeByRefType(); } else { parameter_types[i] = -((int)parameter_types[i] + 1); } } Debug.Assert(parameter_types[i] != null); } return(parameter_types); }