Fix #6, testsuite implemented.
This commit is contained in:
parent
270302bb4b
commit
b359400c83
16 changed files with 268 additions and 3 deletions
|
@ -57,6 +57,10 @@ abstract class Tag {
|
|||
return (_key == null ? "" : _key!);
|
||||
}
|
||||
|
||||
void setKey(String key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
static Tag readNamedTag(ByteLayer data) {
|
||||
var type = data.readByte();
|
||||
if (type == 0) {
|
||||
|
@ -227,4 +231,61 @@ abstract class Tag {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void prettyPrint(int indent, bool recurse);
|
||||
|
||||
static String getCanonicalName(TagType type) {
|
||||
switch (type) {
|
||||
case TagType.String:
|
||||
return "TAG_String";
|
||||
case TagType.List:
|
||||
return "TAG_List";
|
||||
case TagType.LongArray:
|
||||
return "TAG_LongArray";
|
||||
case TagType.Long:
|
||||
return "TAG_Long";
|
||||
case TagType.IntArray:
|
||||
return "TAG_IntArray";
|
||||
case TagType.Int:
|
||||
return "TAG_Int";
|
||||
case TagType.Compound:
|
||||
return "TAG_Compound";
|
||||
case TagType.ByteArray:
|
||||
return "TAG_ByteArray";
|
||||
case TagType.Byte:
|
||||
return "TAG_Byte";
|
||||
case TagType.Double:
|
||||
return "TAG_Double";
|
||||
case TagType.Float:
|
||||
return "TAG_Float";
|
||||
case TagType.Short:
|
||||
return "TAG_Short";
|
||||
case TagType.End:
|
||||
return "TAG_End";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NBTAccountant {
|
||||
static int _prettyIndex = 0;
|
||||
static void printRead(Tag tag) {
|
||||
tag.prettyPrint(_prettyIndex, false);
|
||||
}
|
||||
|
||||
static void visitTag() {
|
||||
_prettyIndex++;
|
||||
}
|
||||
|
||||
static void leaveTag(Tag tag) {
|
||||
if (tag is CompoundTag || tag is ListTag) {
|
||||
if (tag is CompoundTag) {
|
||||
CompoundTag ct = tag as CompoundTag;
|
||||
ct.endPrettyPrint(_prettyIndex);
|
||||
} else if (tag is ListTag) {
|
||||
ListTag lt = tag as ListTag;
|
||||
lt.endPrettyPrint(_prettyIndex);
|
||||
}
|
||||
}
|
||||
_prettyIndex--;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue