more followFars

This commit is contained in:
David Renshaw 2014-06-17 20:35:03 -04:00
parent 9ec8a9b67e
commit 1689a743d2
2 changed files with 23 additions and 1 deletions

View file

@ -1251,6 +1251,9 @@ private:
structNode.getDiscriminantOffset(), ")];\n",
spaces(indent), " }\n")
: kj::strTree()),
spaces(indent), " public final Reader asReader() {\n",
spaces(indent), " return new Reader(this._builder.asReader());\n",
spaces(indent), " }\n",
kj::mv(methodDecls),
spaces(indent), "}\n",
"\n");

View file

@ -112,7 +112,26 @@ final class WireHelpers {
//# so there are no FAR pointers.
if (segment != null && WirePointer.kind(ref) == WirePointer.FAR) {
throw new Error("unimplemented");
SegmentReader resultSegment = segment.arena.tryGetSegment(FarPointer.getSegmentId(ref));
int ptr = FarPointer.positionInSegment(ref);
int padWords = FarPointer.isDoubleFar(ref) ? 2 : 1;
// TODO read limiting
int pad = ptr;
if (!FarPointer.isDoubleFar(ref)) {
return new FollowFarsResult(WirePointer.target(pad,
WirePointer.get(resultSegment.buffer, pad)),
pad, resultSegment);
} else {
//# Landing pad is another far pointer. It is
//# followed by a tag describing the pointed-to
//# object.
throw new Error("unimplemented");
}
} else {
return new FollowFarsResult(refTarget, ref, segment);