2002-10-07
2002-10-07 13:35:40 by Martin Stjernholm <mast@lysator.liu.se>
-
14efc12bb6202eb884483fdbe23d325b2d93d019
(85 lines)
(+47/-38)
[
Show
| Annotate
]
Branch: 5.2
More graceful handling of the case when a context with p-code
compilation activated is used in a recursive parse without
compilation.
Rev: server/etc/modules/RXML.pmod/module.pmod:1.294
2:
//
// Created 1999-07-30 by Martin Stjernholm.
//
- // $Id: module.pmod,v 1.293 2002/10/03 11:49:35 mast Exp $
+ // $Id: module.pmod,v 1.294 2002/10/07 13:35:40 mast Exp $
// Kludge: Must use "RXML.refs" somewhere for the whole module to be
// loaded correctly.
3963:
if (!in_content || in_content == "") flags |= FLAG_MAY_CACHE_RESULT;
content = nil;
}
+
else if (flags & FLAG_UNPARSED) {
#ifdef DEBUG
if (!(flags & FLAG_PROC_INSTR) && !mappingp (args))
3970: Inside #if defined(DEBUG)
if (content && !stringp (content))
fatal_error ("content is not a string in unparsed frame: %O.\n", content);
#endif
+
+ eval_only: {
+ eval_and_compile:
if (ctx->make_p_code) {
if (evaler->is_RXML_PCode) {
if (!(comp = evaler->p_code_comp)) {
comp = evaler->p_code_comp = PikeCompile();
THIS_TAG_TOP_DEBUG ("Evaluating and compiling unparsed"
- " (with new %O in %O)\n", comp, evaler);
+ DO_IF_DEBUG (" (with new %O in %O)\n",
+ comp, evaler));
}
else
THIS_TAG_TOP_DEBUG ("Evaluating and compiling unparsed"
- " (with old %O in %O)\n", comp, evaler);
+ DO_IF_DEBUG (" (with old %O in %O)\n",
+ comp, evaler));
}
-
+
else {
if (!evaler->p_code) {
- #ifdef DEBUG
- fatal_error ("Frame is being compiled but evaler %O "
- "doesn't have a PCode object\n", evaler);
- #endif
- // Handle this gracefully if we're not using debug since this
- // situation can occur easily by mistake if a context is used
- // recursively.
- comp = PikeCompile();
- THIS_TAG_TOP_DEBUG ("Evaluating and compiling unparsed"
- " (with new temporary %O)\n", comp);
+ // This can happen if a context with make_p_code
+ // set is used in a nested parse without
+ // compilation. Just clear it and continue
+ // (orig_make_p_code will restore it afterwards.
+ ctx->make_p_code = 0;
+ break eval_and_compile;
}
-
+
else
if (!(comp = evaler->p_code->p_code_comp)) {
comp = evaler->p_code->p_code_comp = PikeCompile();
THIS_TAG_TOP_DEBUG ("Evaluating and compiling unparsed"
- " (with new %O in %O in %O)\n",
- comp, evaler->p_code, evaler);
+ DO_IF_DEBUG (" (with new %O in %O in %O)\n",
+ comp, evaler->p_code, evaler));
}
else
THIS_TAG_TOP_DEBUG ("Evaluating and compiling unparsed"
- " (with old %O in %O in %O)\n",
- comp, evaler->p_code, evaler);
+ DO_IF_DEBUG (" (with old %O in %O in %O)\n",
+ comp, evaler->p_code, evaler));
}
-
+
in_args = _prepare (ctx, type, args && args + ([]), comp);
PCODE_UPDATE_MSG ("%O: P-code update since args has been compiled.\n",
this_object());
ctx->state_updated++;
-
+ break eval_only;
}
- else {
+
THIS_TAG_TOP_DEBUG ("Evaluating unparsed\n");
_prepare (ctx, type, args && args + ([]), 0);
}
-
+
in_content = content;
if (!in_content || in_content == "") flags |= FLAG_MAY_CACHE_RESULT;
}
-
+
else {
THIS_TAG_TOP_DEBUG ("Evaluating with constant arguments and content\n");
_prepare (ctx, type, 0, 0);