private JSCachedType GetCachedType(TypeReference type) { if (!IsCacheable(type)) { return(null); } bool mapArraysToSystemArray = false; while (type is ByReferenceType) { type = ((ByReferenceType)type).ElementType; } var resolved = TypeUtil.GetTypeDefinition(type, mapArraysToSystemArray); if (resolved == null) { return(null); } var at = type as ArrayType; TypeDefinition[] arguments; var git = type as GenericInstanceType; if (git != null) { arguments = (from a in git.GenericArguments select TypeUtil.GetTypeDefinition(a, mapArraysToSystemArray)).ToArray(); } else { arguments = new TypeDefinition[0]; } var identifier = new GenericTypeIdentifier(resolved, arguments, (at != null) ? at.Rank : 0); CachedTypeRecord record; if (!CachedTypes.TryGetValue(identifier, out record)) { CachedTypes.Add(identifier, record = new CachedTypeRecord(type, NextID++)); } return(new JSCachedType(type, record.Index)); }
private JSCachedType GetCachedType (TypeReference type) { if (!IsCacheable(type)) return null; GenericTypeIdentifier? identifier = GenericTypeIdentifier.Create(type); if (identifier == null) { return null; } CachedTypeRecord record; if (!CachedTypes.TryGetValue(identifier.Value, out record)) CachedTypes.Add(identifier.Value, record = new CachedTypeRecord(type, NextID++)); return new JSCachedType(type, record.Index); }
private JSCachedType GetCachedType(TypeReference type) { if (!IsCacheable(type)) { return(null); } GenericTypeIdentifier?identifier = GenericTypeIdentifier.Create(type); if (identifier == null) { return(null); } CachedTypeRecord record; if (!CachedTypes.TryGetValue(identifier.Value, out record)) { CachedTypes.Add(identifier.Value, record = new CachedTypeRecord(type, NextID++)); } return(new JSCachedType(type, record.Index)); }
private JSCachedType GetCachedType(TypeReference type) { if (!IsCacheable(type)) return null; bool mapArraysToSystemArray = false; while (type is ByReferenceType) type = ((ByReferenceType)type).ElementType; var resolved = TypeUtil.GetTypeDefinition(type, mapArraysToSystemArray); if (resolved == null) return null; var at = type as ArrayType; TypeDefinition[] arguments; var git = type as GenericInstanceType; if (git != null) { arguments = (from a in git.GenericArguments select TypeUtil.GetTypeDefinition(a, mapArraysToSystemArray)).ToArray(); } else { arguments = new TypeDefinition[0]; } var identifier = new GenericTypeIdentifier(resolved, arguments, (at != null) ? at.Rank : 0); CachedTypeRecord record; if (!CachedTypes.TryGetValue(identifier, out record)) CachedTypes.Add(identifier, record = new CachedTypeRecord(type, NextID++)); return new JSCachedType(type, record.Index); }