private string TryGetPrefix(CType t) { string s; try { if (t is CAttrTerm) { CAttrTerm t2 = (CAttrTerm)t; s = t2.AttrStr + " " + ((CPrefix)t2.CoreType).Prefix; } else { s = ((CPrefix)t).Prefix; } } catch (InvalidCastException) { throw new InvalidOperationException(); } return s; }
private CTerm UnwrapType(CType type, out string wrap) { CTerm core; if (type is CWrap) { AttrWrapMaker maker = new AttrWrapMaker(this); type.UnwrapTo(maker, out core); wrap = maker.Value; } else { core = (CTerm)type; wrap = ""; } return core; }
private XmlElement MakeFieldEntry(CType type, string name, Offset offset) { XmlElement result; if (type is CBits) { CBits bit = (CBits)type; result = MakeElem("bit-field"); AddTypeBasicAttrs(result, bit.Next, false); AddNameAndOffsetAttrs(result, name, offset); AddAttr(result, "len", bit.Len); } else { result = MakeElem("field"); AddTypeBasicAttrs(result, type, true); AddNameAndOffsetAttrs(result, name, offset); } return result; }
private void AddTypeBasicAttrs(XmlElement elem, CType type, bool writeWrap) { string a_attr, a_base, a_wrap; CTerm core, inner; core = UnwrapType(type, out a_wrap); inner = StripTypeAttr(core, out a_attr); a_base = EncodeBaseType(inner); if (a_attr != "") { AddAttr(elem, "attr", a_attr); } AddAttr(elem, "base", a_base); if (writeWrap) { AddAttr(elem, "wrap", a_wrap); } }
public Entry(CType type, string name, Offset offset) { _type = type; _name = name; _offset = offset; }
public void Add(CType type, string name) { Add(type, name, Offset.Zero); }
public void Add(CType type, string name, Offset offset) { _entries.Add(new Entry(type, name, offset)); }
public void Add(CType type) { _args.Add(type); }
public CArr(CType next, int len) : base(next) { _len = len; }
public CFunc(CType retType, CallConv callConv) : base(retType) { _args = new List<CType>(); _callConv = callConv; }
public CFunc(CType retType) : this(retType, CallConvs.Default) { }
public CWrap(CType next) { _next = next; }
public CPtr(CType next) : base(next) { }