public bool Validate(CodeGenerationOptions opt, GenericParameterDefinitionList in_params) { if (validated) { return(is_valid); } validated = true; is_concrete = true; type_params = new ISymbol [java_params.Length]; for (int i = 0; i < java_params.Length; i++) { string tp = java_params [i].TrimStart(); var gpd = in_params != null?in_params.FirstOrDefault(t => t.Name == tp) : null; if (in_params != null && gpd != null) { type_params [i] = new GenericTypeParameter(gpd); is_concrete = false; continue; } else if (tp == "?") { if (in_params != null && in_params.Count == 1) { type_params [i] = new GenericTypeParameter(in_params [0]); is_concrete = false; } else { type_params [i] = new SimpleSymbol("null", "java.lang.Object", "object", "Ljava/lang/Object;"); } continue; } ISymbol psym = opt.SymbolTable.Lookup(tp, in_params); if (psym == null || !psym.Validate(opt, in_params)) { return(false); } if (psym is GenericSymbol && !(psym as GenericSymbol).IsConcrete) { is_concrete = false; } type_params [i] = /*psym is IGeneric ? (psym as IGeneric).GetGenericType (null) :*/ psym; } managed = "<" + String.Join(", ", (from tp in type_params select tp.FullName).ToArray()) + ">"; is_valid = true; return(true); }
public static ISymbol Lookup(string java_type, GenericParameterDefinitionList in_params) { string type_params; int arrayRank; bool has_ellipsis; string key = GetSymbolInfo(java_type, out type_params, out arrayRank, out has_ellipsis); // FIXME: we should make sure to differentiate those ref types IF we use those modifiers in the future. switch (key [key.Length - 1]) { case '&': // managed ref type case '*': // managed (well, unmanaged...) pointer type key = key.Substring(0, key.Length - 1); break; } key = FilterPrimitiveFullName(key) ?? key; switch (key) { case "android.content.res.XmlResourceParser": return(CreateArray(xmlresourceparser_sym, arrayRank, has_ellipsis)); case "org.xmlpull.v1.XmlPullParser": return(CreateArray(xmlpullparser_sym, arrayRank, has_ellipsis)); case "java.io.FileInputStream": return(CreateArray(fileinstream_sym, arrayRank, has_ellipsis)); case "java.io.FileOutputStream": return(CreateArray(fileoutstream_sym, arrayRank, has_ellipsis)); case "java.io.InputStream": return(CreateArray(instream_sym, arrayRank, has_ellipsis)); case "java.io.OutputStream": return(CreateArray(outstream_sym, arrayRank, has_ellipsis)); case "java.lang.CharSequence": return(CreateArray(char_seq, arrayRank, has_ellipsis)); case "java.lang.String": return(CreateArray(string_sym, arrayRank, has_ellipsis)); case "java.util.List": case "java.util.ArrayList": case "System.Collections.IList": return(CreateArray(new CollectionSymbol(key, "IList", "Android.Runtime.JavaList", type_params), arrayRank, has_ellipsis)); case "java.util.Map": case "java.util.HashMap": case "java.util.SortedMap": case "System.Collections.IDictionary": return(CreateArray(new CollectionSymbol(key, "IDictionary", "Android.Runtime.JavaDictionary", type_params), arrayRank, has_ellipsis)); case "java.util.Set": return(CreateArray(new CollectionSymbol(key, "ICollection", "Android.Runtime.JavaSet", type_params), arrayRank, has_ellipsis)); case "java.util.Collection": case "System.Collections.ICollection": return(CreateArray(new CollectionSymbol(key, "ICollection", "Android.Runtime.JavaCollection", type_params), arrayRank, has_ellipsis)); default: break; } ISymbol result; var gpd = in_params != null?in_params.FirstOrDefault(t => t.Name == key) : null; if (gpd != null) { result = new GenericTypeParameter(gpd); } else { result = Lookup(key + type_params); } return(CreateArray(result, arrayRank, has_ellipsis)); }