440 |
return scm_eval_string (scm_makfrom0str (expr)); |
return scm_eval_string (scm_makfrom0str (expr)); |
441 |
} |
} |
442 |
|
|
443 |
|
SCM |
444 |
|
scm_c_eval_string_in_module (const char *expr, SCM module) |
445 |
|
{ |
446 |
|
return scm_eval_string_in_module (scm_makfrom0str (expr), module); |
447 |
|
} |
448 |
|
|
449 |
|
|
450 |
static SCM |
static SCM |
451 |
inner_eval_string (void *data) |
inner_eval_string (void *data) |
452 |
{ |
{ |
466 |
return ans; |
return ans; |
467 |
} |
} |
468 |
|
|
469 |
SCM_DEFINE (scm_eval_string, "eval-string", 1, 0, 0, |
SCM_DEFINE (scm_eval_string_in_module, "eval-string", 1, 1, 0, |
470 |
(SCM string), |
(SCM string, SCM module), |
471 |
"Evaluate @var{string} as the text representation of a Scheme\n" |
"Evaluate @var{string} as the text representation of a Scheme\n" |
472 |
"form or forms, and return whatever value they produce.\n" |
"form or forms, and return whatever value they produce.\n" |
473 |
"Evaluation takes place in the environment returned by the\n" |
"Evaluation takes place in the given module, or the current\n" |
474 |
"procedure @code{interaction-environment}.") |
"module when no module is given.\n" |
475 |
#define FUNC_NAME s_scm_eval_string |
"While the code is evaluated, the given module is made the\n" |
476 |
|
"current one. The current module is restored when this\n" |
477 |
|
"procedure returns.") |
478 |
|
#define FUNC_NAME s_scm_eval_string_in_module |
479 |
{ |
{ |
480 |
SCM port = scm_mkstrport (SCM_INUM0, string, SCM_OPN | SCM_RDNG, |
SCM port = scm_mkstrport (SCM_INUM0, string, SCM_OPN | SCM_RDNG, |
481 |
"eval-string"); |
FUNC_NAME); |
482 |
return scm_c_call_with_current_module (scm_interaction_environment (), |
if (SCM_UNBNDP (module)) |
483 |
|
module = scm_current_module (); |
484 |
|
return scm_c_call_with_current_module (module, |
485 |
inner_eval_string, (void *)port); |
inner_eval_string, (void *)port); |
486 |
} |
} |
487 |
#undef FUNC_NAME |
#undef FUNC_NAME |
488 |
|
|
489 |
|
SCM |
490 |
|
scm_eval_string (SCM string) |
491 |
|
{ |
492 |
|
return scm_eval_string_in_module (string, SCM_UNDEFINED); |
493 |
|
} |
494 |
|
|
495 |
static scm_t_bits |
static scm_t_bits |
496 |
scm_make_stptob () |
scm_make_stptob () |
497 |
{ |
{ |