re->source = str; re->lastIndex = 0;
js_NewRegExp(JSContext *cx, JSTokenStream *ts,             JSString *str, uintN flags, JSBool flat){    JSRegExp *re;    void *mark;    CompilerState state;    RENode *ren, *ren2, *end;    size_t resize;    const jschar *cp;    size_t len;    re = NULL;    mark = JS_ARENA_MARK(&cx->tempPool);    state.context = cx;    state.tokenStream = ts;    state.cpbegin = state.cp = JSSTRING_CHARS(str);    state.cpend = state.cp + JSSTRING_LENGTH(str);    state.flags = flags;    state.parenCount = 0;    state.progLength = 0;    len = JSSTRING_LENGTH(str);    if (len != 0 && flat) {        cp = state.cpbegin;        ren = NULL;        do {            ren2 = NewRENode(&state,                              (len == 1) ? REOP_FLAT1 : REOP_FLAT,                             (void *)cp);	    if (!ren2)	        goto out;	    ren2->flags = RENODE_NONEMPTY;	    if (len > 1) {                if (len > REOP_FLATLEN_MAX) {                    cp += REOP_FLATLEN_MAX;                    len -= REOP_FLATLEN_MAX;                }                else {                    cp += len;                    len = 0;                }	        ren2->u.kid2 = (void *)cp;                	    } else {	        ren2->flags |= RENODE_SINGLE;	        ren2->u.chr = *cp;                len = 0;            }            if (ren) {                if (!SetNext(&state, ren, ren2))                    goto out;            }            else                ren = ren2;        } while (len > 0);    }    else        ren = ParseRegExp(&state);    if (!ren)	goto out;    end = NewRENode(&state, REOP_END, NULL);    if (!end || !SetNext(&state, ren, end))	goto out;#ifdef DEBUG_notme    if (!DumpRegExp(cx, ren))	goto out;#endif    resize = sizeof *re + state.progLength - 1;    re = (JSRegExp *) JS_malloc(cx, JS_ROUNDUP(resize, sizeof(jsword)));    if (!re)	goto out;    re->nrefs = 1;    re->source = str;    re->lastIndex = 0;    re->parenCount = state.parenCount;    re->flags = flags;#ifdef JS_THREADSAFE    re->owningThread = 0;    re->lastIndexes = NULL;#endif    re->ren = ren;out:    JS_ARENA_RELEASE(&cx->tempPool, mark);    return re;}