VariableInfo (VariableInfo parent, TypeInfo type) { this.Name = parent.Name; this.TypeInfo = type; this.Offset = parent.Offset + type.Offset; this.Length = type.TotalLength; this.IsParameter = parent.IsParameter; Initialize (); }
// // We only need one instance per type // StructInfo (TypeSpec type) { field_type_hash.Add (type, this); fields = MemberCache.GetAllFieldsForDefiniteAssignment (type); struct_field_hash = new Dictionary<string, TypeInfo> (); field_hash = new Dictionary<string, int> (fields.Count); StructFields = new TypeInfo[fields.Count]; StructInfo[] sinfo = new StructInfo[fields.Count]; InTransit = true; for (int i = 0; i < fields.Count; i++) { var field = fields [i]; if (field.MemberType.IsStruct) sinfo [i] = GetStructInfo (field.MemberType); if (sinfo [i] == null) field_hash.Add (field.Name, ++Length); else if (sinfo [i].InTransit) { sinfo [i] = null; return; } } InTransit = false; TotalLength = Length + 1; for (int i = 0; i < fields.Count; i++) { var field = fields [i]; if (sinfo [i] == null) continue; field_hash.Add (field.Name, TotalLength); StructFields [i] = new TypeInfo (sinfo [i], TotalLength); struct_field_hash.Add (field.Name, StructFields [i]); TotalLength += sinfo [i].TotalLength; } }
VariableInfo (string name, TypeSpec type, int offset) { this.Name = name; this.Offset = offset; this.TypeInfo = TypeInfo.GetTypeInfo (type); Length = TypeInfo.TotalLength; Initialize (); }
public static TypeInfo GetTypeInfo (TypeSpec type) { if (!type.IsStruct) return simple_type; TypeInfo info; if (type_hash.TryGetValue (type, out info)) return info; var struct_info = StructInfo.GetStructInfo (type); if (struct_info != null) { info = new TypeInfo (struct_info, 0); } else { info = simple_type; } type_hash.Add (type, info); return info; }