/************************ Utility Methods **************************/ private string getStructName(FrontEnd.CbType t) { string name = null; if (t is FrontEnd.CbStruct) { FrontEnd.CbStruct s = (FrontEnd.CbStruct)t; name = s.Name; } return(name); }
// returns the size of a type private int getTypeSize(FrontEnd.CbType t) { //Console.WriteLine("gTS: Type is '{0}'", t); if (t == FrontEnd.CbType.Int || t == FrontEnd.CbType.String || t is FrontEnd.CbArray) { return(4); // ints are words, and so are pointers to strings and arrays } else if (t is FrontEnd.CbStruct) { FrontEnd.CbStruct s = (FrontEnd.CbStruct)t; int size = 0; foreach (FrontEnd.CbField f in s.Fields.Values) { size += getTypeSize(f.Type); } return(size); } else { throw new Exception("getTypeSize: Unknown type: " + t); } }