/// <summary> /// Add a "global" field to this module /// </summary> /// <param name="name">field name</param> /// <param name="fType">field type</param> /// <returns>a descriptor for this new "global" field</returns> public FieldDef AddField(string name, Type fType) { //FIXME Contract.Requires(defaultClass != null); FieldDef newField = defaultClass.AddField(name, fType); return(newField); }
public Field GetReference(TypeRef type, string name, Location location) { FieldTableItem item = table[name] as FieldTableItem; if (item != null) { item.LocationList.Add(location); return(item.Field); } FieldDef field = parent_class.AddField(name, type.Type); AddReferenced(name, field, location); return(field); }
/// <summary> /// Find the Field for this field on the given type. /// </summary> internal Field findField(string qname, string fieldName, string fieldType) { string key = qname + "/F" + fieldName; Field field = (Field)fields[key]; if (field == null) { // should be same for both cases PERWAPI.Type ftype = findType(fieldType); // check for stubs object obj = findType(qname); if (obj is ClassDef) { // class is an internal stub, so we need to stub this field // out too, which is actually complete and not a stub ClassDef cdef = obj as ClassDef; // TODO - fix attr field = cdef.AddField(FieldAttr.Public, fieldName, ftype); } else if (obj is ClassRef) { // class is external, just get or add ref ClassRef cref = obj as ClassRef; field = cref.GetField(fieldName); if (field == null) { field = cref.AddField(fieldName, ftype); } } else { throw new System.Exception("Don't know how to handle: " + obj.GetType()); } // remember to add field to lookup table fields[key] = field; } return(field); }