public static string GetScriptName(AstType type, bool separator) { string result = null; SimpleType simpleType = type as SimpleType; if (simpleType != null) { result = Helpers.GetScriptName(simpleType.Identifier, simpleType.TypeArguments.Count, separator); } else { PrimitiveType primType = type as PrimitiveType; if (primType != null) { result = Helpers.GetScriptName(primType.KnownTypeCode.ToString(), 0, separator); } else { result = Helpers.GetScriptName(type.ToString(), 0, separator); } } var composedType = type as ComposedType; if (composedType != null) { result = Helpers.GetScriptName(composedType.BaseType, separator) + "." + result; } return(result); }
public static string TranslateTypeReference(AstType astType, IEmitter emitter) { var composedType = astType as ComposedType; if (composedType != null && composedType.ArraySpecifiers != null && composedType.ArraySpecifiers.Count > 0) { return("Array"); } var simpleType = astType as SimpleType; if (simpleType != null && simpleType.Identifier == "dynamic") { return("Object"); } string type = emitter.ResolveType(Helpers.GetScriptName(astType, true), astType); if (String.IsNullOrEmpty(type)) { throw (Exception)emitter.CreateException(astType, "Cannot resolve type " + astType.ToString()); } var name = type; if (emitter.TypeDefinitions.ContainsKey(name)) { name = emitter.ShortenTypeName(type); } if (simpleType != null && simpleType.TypeArguments.Count > 0 && !Helpers.IsIgnoreGeneric(simpleType, emitter)) { StringBuilder sb = new StringBuilder(name); bool needComma = false; sb.Append("("); foreach (var typeArg in simpleType.TypeArguments) { if (needComma) { sb.Append(","); } needComma = true; sb.Append(Helpers.TranslateTypeReference(typeArg, emitter)); } sb.Append(")"); name = sb.ToString(); } return(name); }
public static bool IsIgnoreCast(AstType astType, IEmitter emitter) { var fullname = emitter.ResolveType(Helpers.GetScriptName(astType, true), astType); if (emitter.TypeDefinitions.ContainsKey(fullname)) { var typeDef = emitter.TypeDefinitions[fullname]; if (emitter.Validator.HasAttribute(typeDef.CustomAttributes, "Bridge.IgnoreCastAttribute")) { return(true); } } return(false); }
public static string GetScriptName(TypeDeclaration type, bool separator) { return(Helpers.GetScriptName(type.Name, type.TypeParameters.Count, separator)); }
public static string GetScriptName(MethodDefinition method, bool separator) { return(Helpers.GetScriptName(method.Name, method.GenericParameters.Count, separator)); }
public static string GetScriptName(MemberReferenceExpression member, bool separator) { return(Helpers.GetScriptName(member.MemberName, member.TypeArguments.Count, separator)); }
public static string GetScriptName(OperatorDeclaration op, bool separator) { return(Helpers.GetScriptName(op.Name, op.Parameters.Count, separator)); }