public IntegerValue sizeof(Context ctxt) { IntegerValue size = new IntegerValue(0); IntegerValue eight = new IntegerValue(8); for (int i = 0; i < fields.size(); i++) { Field fi = (Field) fields.elementAt(i); /* TODO: try { StdIntegerType b = StdIntegerType.getBuiltinType(fi.getFieldType()); if (b instanceof BitFieldType) { size = size.add(new IntegerValue(((BitFieldType) b) .getLength())); continue; } } catch (ClassCastException _) { } */ size = size.add(fi.sizeof(ctxt).multiply(eight)); } return size.divide(eight); }
public IntegerValue sizeof(Context ctxt) { IntegerValue eight = new IntegerValue(8); IntegerValue size = bitsizeof(ctxt); if (size.remainder(eight).compareTo(new IntegerValue(0)) != 0) { throw new RuntimeException("sizeof not integer: " + size); } return size.divide(eight); }