mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Issue 114: Allow compile time limits to be configured.
This commit is contained in:
4
jsdump.c
4
jsdump.c
@@ -799,7 +799,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
|
|||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case OP_INTEGER:
|
case OP_INTEGER:
|
||||||
printf(" %d", (*p++) - 32768);
|
printf(" %ld", (long)((*p++) - 32768));
|
||||||
break;
|
break;
|
||||||
case OP_NUMBER:
|
case OP_NUMBER:
|
||||||
printf(" %.9g", F->numtab[*p++]);
|
printf(" %.9g", F->numtab[*p++]);
|
||||||
@@ -840,7 +840,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F)
|
|||||||
case OP_JFALSE:
|
case OP_JFALSE:
|
||||||
case OP_JCASE:
|
case OP_JCASE:
|
||||||
case OP_TRY:
|
case OP_TRY:
|
||||||
printf(" %d", *p++);
|
printf(" %ld", (long)*p++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
jsi.h
15
jsi.h
@@ -69,14 +69,29 @@ typedef struct js_StackTrace js_StackTrace;
|
|||||||
|
|
||||||
/* Limits */
|
/* Limits */
|
||||||
|
|
||||||
|
#ifndef JS_STACKSIZE
|
||||||
#define JS_STACKSIZE 256 /* value stack size */
|
#define JS_STACKSIZE 256 /* value stack size */
|
||||||
|
#endif
|
||||||
|
#ifndef JS_ENVLIMIT
|
||||||
#define JS_ENVLIMIT 64 /* environment stack size */
|
#define JS_ENVLIMIT 64 /* environment stack size */
|
||||||
|
#endif
|
||||||
|
#ifndef JS_TRYLIMIT
|
||||||
#define JS_TRYLIMIT 64 /* exception stack size */
|
#define JS_TRYLIMIT 64 /* exception stack size */
|
||||||
|
#endif
|
||||||
|
#ifndef JS_GCLIMIT
|
||||||
#define JS_GCLIMIT 10000 /* run gc cycle every N allocations */
|
#define JS_GCLIMIT 10000 /* run gc cycle every N allocations */
|
||||||
|
#endif
|
||||||
|
#ifndef JS_ASTLIMIT
|
||||||
#define JS_ASTLIMIT 100 /* max nested expressions */
|
#define JS_ASTLIMIT 100 /* max nested expressions */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* instruction size -- change to int if you get integer overflow syntax errors */
|
/* instruction size -- change to int if you get integer overflow syntax errors */
|
||||||
|
|
||||||
|
#ifdef JS_INSTRUCTION
|
||||||
|
typedef JS_INSTRUCTION js_Instruction;
|
||||||
|
#else
|
||||||
typedef unsigned short js_Instruction;
|
typedef unsigned short js_Instruction;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* String interning */
|
/* String interning */
|
||||||
|
|
||||||
|
|||||||
18
regexp.c
18
regexp.c
@@ -14,9 +14,21 @@
|
|||||||
#define nelem(a) (int)(sizeof (a) / sizeof (a)[0])
|
#define nelem(a) (int)(sizeof (a) / sizeof (a)[0])
|
||||||
|
|
||||||
#define REPINF 255
|
#define REPINF 255
|
||||||
|
#ifndef MAXSUB
|
||||||
#define MAXSUB REG_MAXSUB
|
#define MAXSUB REG_MAXSUB
|
||||||
|
#endif
|
||||||
|
#ifndef MAXPROG
|
||||||
#define MAXPROG (32 << 10)
|
#define MAXPROG (32 << 10)
|
||||||
|
#endif
|
||||||
|
#ifndef MAXREC
|
||||||
#define MAXREC 1024
|
#define MAXREC 1024
|
||||||
|
#endif
|
||||||
|
#ifndef MAXSPAN
|
||||||
|
#define MAXSPAN 64
|
||||||
|
#endif
|
||||||
|
#ifndef MAXCLASS
|
||||||
|
#define MAXCLASS 16
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct Reclass Reclass;
|
typedef struct Reclass Reclass;
|
||||||
typedef struct Renode Renode;
|
typedef struct Renode Renode;
|
||||||
@@ -25,14 +37,14 @@ typedef struct Rethread Rethread;
|
|||||||
|
|
||||||
struct Reclass {
|
struct Reclass {
|
||||||
Rune *end;
|
Rune *end;
|
||||||
Rune spans[64];
|
Rune spans[MAXSPAN];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Reprog {
|
struct Reprog {
|
||||||
Reinst *start, *end;
|
Reinst *start, *end;
|
||||||
int flags;
|
int flags;
|
||||||
int nsub;
|
int nsub;
|
||||||
Reclass cclass[16];
|
Reclass cclass[MAXCLASS];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cstate {
|
struct cstate {
|
||||||
@@ -194,7 +206,7 @@ static void addrange(struct cstate *g, Rune a, Rune b)
|
|||||||
{
|
{
|
||||||
if (a > b)
|
if (a > b)
|
||||||
die(g, "invalid character class range");
|
die(g, "invalid character class range");
|
||||||
if (g->yycc->end + 2 == g->yycc->spans + nelem(g->yycc->spans))
|
if (g->yycc->end + 2 >= g->yycc->spans + nelem(g->yycc->spans))
|
||||||
die(g, "too many character class ranges");
|
die(g, "too many character class ranges");
|
||||||
*g->yycc->end++ = a;
|
*g->yycc->end++ = a;
|
||||||
*g->yycc->end++ = b;
|
*g->yycc->end++ = b;
|
||||||
|
|||||||
Reference in New Issue
Block a user