forked from weaselab/weaseljson
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#if __has_attribute(musttail)
|
#if __has_attribute(musttail)
|
||||||
#define MUSTTAIL __attribute__((musttail))
|
#define MUSTTAIL __attribute__((musttail))
|
||||||
|
#define HAS_MUSTTAIL
|
||||||
#else
|
#else
|
||||||
#define MUSTTAIL
|
#define MUSTTAIL
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -146,6 +146,10 @@ struct Parser3 {
|
|||||||
NumDfa numDfa;
|
NumDfa numDfa;
|
||||||
Utf8Dfa strDfa;
|
Utf8Dfa strDfa;
|
||||||
bool inKey = false;
|
bool inKey = false;
|
||||||
|
|
||||||
|
#ifndef HAS_MUSTTAIL
|
||||||
|
char *stashBufForTrampoline;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PRESERVE_NONE WeaselJsonStatus skipWhitespace(char *&buf, char *bufEnd) {
|
inline PRESERVE_NONE WeaselJsonStatus skipWhitespace(char *&buf, char *bufEnd) {
|
||||||
@@ -1029,13 +1033,29 @@ constexpr inline struct ContinuationTable {
|
|||||||
|
|
||||||
inline WeaselJsonStatus Parser3::parse(char *buf, int len) {
|
inline WeaselJsonStatus Parser3::parse(char *buf, int len) {
|
||||||
this->dataBegin = this->writeBuf = buf;
|
this->dataBegin = this->writeBuf = buf;
|
||||||
|
|
||||||
|
#ifdef HAS_MUSTTAIL
|
||||||
return symbolTables.continuations[top()](this, buf, buf + len);
|
return symbolTables.continuations[top()](this, buf, buf + len);
|
||||||
|
#else
|
||||||
|
this->stashBufForTrampoline = buf;
|
||||||
|
WeaselJsonStatus result;
|
||||||
|
while ((result = symbolTables.continuations[top()](
|
||||||
|
this, stashBufForTrampoline, buf + len)) == WeaselJsonStatus(-1))
|
||||||
|
;
|
||||||
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PRESERVE_NONE WeaselJsonStatus Parser3::keepGoing(Parser3 *self,
|
inline PRESERVE_NONE WeaselJsonStatus Parser3::keepGoing(Parser3 *self,
|
||||||
char *buf,
|
char *buf,
|
||||||
char *bufEnd) {
|
char *bufEnd) {
|
||||||
|
#ifdef HAS_MUSTTAIL
|
||||||
MUSTTAIL return symbolTables.continuations[self->top()](self, buf, bufEnd);
|
MUSTTAIL return symbolTables.continuations[self->top()](self, buf, bufEnd);
|
||||||
|
#else
|
||||||
|
self->stashBufForTrampoline = buf;
|
||||||
|
(void)bufEnd;
|
||||||
|
return WeaselJsonStatus(-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace parser3
|
} // namespace parser3
|
||||||
|
|||||||
Reference in New Issue
Block a user