} posix_regmatch_t;
-#ifdef __GNUC__
-#define USE_THREADED_CODE
-#endif
#ifdef USE_THREADED_CODE
#define DEFAULT_OP /* L_DEFAULT: */
#define NEXT_OP sprev = sbegin; JUMP_OP
#define JUMP_OP GOTO_OP
+#ifdef USE_DIRECT_THREADED_CODE
+#define GOTO_OP goto *(p->opaddr)
+#else
#define GOTO_OP goto *opcode_to_label[p->opcode]
+#endif
#define BREAK_OP /* Nothing */
#else
const UChar* in_right_range, const UChar* sstart, UChar* sprev,
MatchArg* msa)
{
- static Operation FinishCode[] = { { OP_FINISH } };
+
+#if defined(USE_THREADED_CODE) && defined(USE_DIRECT_THREADED_CODE)
+ static Operation FinishCode[] = { { {.opaddr=&&L_FINISH} } };
+#else
+ static Operation FinishCode[] = { { {OP_FINISH} } };
+#endif
#ifdef USE_THREADED_CODE
static const void *opcode_to_label[] = {
static unsigned int counter = 1;
#endif
+#ifdef USE_THREADED_CODE
+#ifdef USE_DIRECT_THREADED_CODE
+ if (IS_NULL(msa)) {
+ for (i = 0; i < reg->ops_used; i++) {
+ const void* addr;
+ /* fprintf(stdout, "code: %d, ", p->opcode); */
+ addr = opcode_to_label[p->opcode];
+ p->opaddr = addr;
+ /* fprintf(stdout, "addr: %p\n", p->opaddr); */
+ p++;
+ }
+ return ONIG_NORMAL;
+ }
+#endif
+#endif
+
#ifdef USE_CALLOUT
msa->mp->match_at_call_counter++;
#endif
fprintf(stderr, "EMPTY_CHECK_END: skip id:%d, s:%p\n", (int )mem, s);
#endif
empty_check_found:
- /* empty loop founded, skip next instruction */
- switch (p->opcode) {
- case OP_JUMP:
- case OP_PUSH:
- case OP_REPEAT_INC:
- case OP_REPEAT_INC_NG:
- case OP_REPEAT_INC_SG:
- case OP_REPEAT_INC_NG_SG:
- INC_OP;
- break;
- default:
- goto unexpected_bytecode_error;
- break;
- }
+ INC_OP;
}
}
JUMP_OUT;
STACK_SAVE;
return ONIGERR_UNDEFINED_BYTECODE;
- unexpected_bytecode_error:
- STACK_SAVE;
- return ONIGERR_UNEXPECTED_BYTECODE;
-
#ifdef USE_RETRY_LIMIT_IN_MATCH
retry_limit_in_match_over:
STACK_SAVE;
return ONIG_NORMAL;
}
+#ifdef USE_THREADED_CODE
+#ifdef USE_DIRECT_THREADED_CODE
+extern int
+onig_init_for_match_at(regex_t* reg)
+{
+ return match_at(reg, (const UChar* )NULL, (const UChar* )NULL,
+ (const UChar* )NULL, (const UChar* )NULL, (UChar* )NULL,
+ (MatchArg* )NULL);
+}
+#endif
+#endif
+
/* builtin callout functions */
#define PLATFORM_UNALIGNED_WORD_ACCESS
#endif
+#ifdef __GNUC__
+#define USE_THREADED_CODE
+#endif
+
/* config */
/* spec. config */
#define USE_CALL
#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
#define USE_RETRY_LIMIT_IN_MATCH
+#ifdef USE_THREADED_CODE
+#define USE_DIRECT_THREADED_CODE
+#endif
/* internal config */
#define USE_OP_PUSH_OR_JUMP_EXACT
typedef struct {
- enum OpCode opcode;
+ union {
+ enum OpCode opcode;
+ const void* opaddr;
+ };
union {
struct {
UChar* s;