mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 01:30:27 +02:00
Add "mod" field to tree-il toplevel ref, set, define
Add "mod" field to <toplevel-ref>, <toplevel-set>, and <toplevel-define>, indicating the expander's idea of what the current module is when a toplevel variable is accessed or created. This will help in later optimizations. * libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE) (expand, expand_define, expand_set_x, convert_assignment): * libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES): (SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE): * module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects): * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm: * module/language/tree-il.scm: * module/language/tree-il.scm (parse-tree-il, make-tree-il-folder): (pre-post-order): * module/language/tree-il/analyze.scm (goops-toplevel-definition): (macro-use-before-definition-analysis, proc-ref?, format-analysis): * module/language/tree-il/compile-cps.scm (convert): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/fix-letrec.scm (free-variables): * module/language/tree-il/peval.scm (peval): * test-suite/tests/tree-il.test: Adapt uses.
This commit is contained in:
parent
4bb5834d75
commit
79a40cf717
13 changed files with 182 additions and 156 deletions
|
@ -74,12 +74,12 @@ static const char** exp_field_names[SCM_NUM_EXPANDED_TYPES];
|
|||
SCM_MAKE_EXPANDED_MODULE_REF(src, mod, name, public)
|
||||
#define MODULE_SET(src, mod, name, public, exp) \
|
||||
SCM_MAKE_EXPANDED_MODULE_SET(src, mod, name, public, exp)
|
||||
#define TOPLEVEL_REF(src, name) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_REF(src, name)
|
||||
#define TOPLEVEL_SET(src, name, exp) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_SET(src, name, exp)
|
||||
#define TOPLEVEL_DEFINE(src, name, exp) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE(src, name, exp)
|
||||
#define TOPLEVEL_REF(src, mod, name) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_REF(src, mod, name)
|
||||
#define TOPLEVEL_SET(src, mod, name, exp) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_SET(src, mod, name, exp)
|
||||
#define TOPLEVEL_DEFINE(src, mod, name, exp) \
|
||||
SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE(src, mod, name, exp)
|
||||
#define CONDITIONAL(src, test, consequent, alternate) \
|
||||
SCM_MAKE_EXPANDED_CONDITIONAL(src, test, consequent, alternate)
|
||||
#define PRIMCALL(src, name, exps) \
|
||||
|
@ -377,7 +377,7 @@ expand (SCM exp, SCM env)
|
|||
if (scm_is_true (gensym))
|
||||
return LEXICAL_REF (SCM_BOOL_F, exp, gensym);
|
||||
else
|
||||
return TOPLEVEL_REF (SCM_BOOL_F, exp);
|
||||
return TOPLEVEL_REF (SCM_BOOL_F, SCM_BOOL_F, exp);
|
||||
}
|
||||
else
|
||||
return CONST_ (SCM_BOOL_F, exp);
|
||||
|
@ -552,13 +552,14 @@ expand_define (SCM expr, SCM env)
|
|||
ASSERT_SYNTAX_2 (scm_is_symbol (CAR (variable)), s_bad_variable, variable, expr);
|
||||
return TOPLEVEL_DEFINE
|
||||
(scm_source_properties (expr),
|
||||
SCM_BOOL_F,
|
||||
CAR (variable),
|
||||
expand_lambda (scm_cons (scm_sym_lambda, scm_cons (CDR (variable), body)),
|
||||
env));
|
||||
}
|
||||
ASSERT_SYNTAX_2 (scm_is_symbol (variable), s_bad_variable, variable, expr);
|
||||
ASSERT_SYNTAX (scm_ilength (body) == 1, s_expression, expr);
|
||||
return TOPLEVEL_DEFINE (scm_source_properties (expr), variable,
|
||||
return TOPLEVEL_DEFINE (scm_source_properties (expr), SCM_BOOL_F, variable,
|
||||
expand (CAR (body), env));
|
||||
}
|
||||
|
||||
|
@ -1143,6 +1144,7 @@ expand_set_x (SCM expr, SCM env)
|
|||
expand (CADDR (expr), env));
|
||||
case SCM_EXPANDED_TOPLEVEL_REF:
|
||||
return TOPLEVEL_SET (scm_source_properties (expr),
|
||||
SCM_EXPANDED_REF (vmem, TOPLEVEL_REF, MOD),
|
||||
SCM_EXPANDED_REF (vmem, TOPLEVEL_REF, NAME),
|
||||
expand (CADDR (expr), env));
|
||||
case SCM_EXPANDED_MODULE_REF:
|
||||
|
@ -1371,12 +1373,14 @@ convert_assignment (SCM exp, SCM assigned)
|
|||
case SCM_EXPANDED_TOPLEVEL_SET:
|
||||
return TOPLEVEL_SET
|
||||
(REF (exp, TOPLEVEL_SET, SRC),
|
||||
REF (exp, TOPLEVEL_SET, MOD),
|
||||
REF (exp, TOPLEVEL_SET, NAME),
|
||||
convert_assignment (REF (exp, TOPLEVEL_SET, EXP), assigned));
|
||||
|
||||
case SCM_EXPANDED_TOPLEVEL_DEFINE:
|
||||
return TOPLEVEL_DEFINE
|
||||
(REF (exp, TOPLEVEL_DEFINE, SRC),
|
||||
REF (exp, TOPLEVEL_DEFINE, MOD),
|
||||
REF (exp, TOPLEVEL_DEFINE, NAME),
|
||||
convert_assignment (REF (exp, TOPLEVEL_DEFINE, EXP),
|
||||
assigned));
|
||||
|
|
|
@ -175,41 +175,44 @@ enum
|
|||
|
||||
#define SCM_EXPANDED_TOPLEVEL_REF_TYPE_NAME "toplevel-ref"
|
||||
#define SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES \
|
||||
{ "src", "name", }
|
||||
{ "src", "mod", "name", }
|
||||
enum
|
||||
{
|
||||
SCM_EXPANDED_TOPLEVEL_REF_SRC,
|
||||
SCM_EXPANDED_TOPLEVEL_REF_MOD,
|
||||
SCM_EXPANDED_TOPLEVEL_REF_NAME,
|
||||
SCM_NUM_EXPANDED_TOPLEVEL_REF_FIELDS,
|
||||
};
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_REF(src, name) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_REF], 0, SCM_NUM_EXPANDED_TOPLEVEL_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name))
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_REF(src, mod, name) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_REF], 0, SCM_NUM_EXPANDED_TOPLEVEL_REF_FIELDS, SCM_UNPACK (src), SCM_UNPACK (mod), SCM_UNPACK (name))
|
||||
|
||||
#define SCM_EXPANDED_TOPLEVEL_SET_TYPE_NAME "toplevel-set"
|
||||
#define SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES \
|
||||
{ "src", "name", "exp", }
|
||||
{ "src", "mod", "name", "exp", }
|
||||
enum
|
||||
{
|
||||
SCM_EXPANDED_TOPLEVEL_SET_SRC,
|
||||
SCM_EXPANDED_TOPLEVEL_SET_MOD,
|
||||
SCM_EXPANDED_TOPLEVEL_SET_NAME,
|
||||
SCM_EXPANDED_TOPLEVEL_SET_EXP,
|
||||
SCM_NUM_EXPANDED_TOPLEVEL_SET_FIELDS,
|
||||
};
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_SET(src, name, exp) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_SET], 0, SCM_NUM_EXPANDED_TOPLEVEL_SET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (exp))
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_SET(src, mod, name, exp) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_SET], 0, SCM_NUM_EXPANDED_TOPLEVEL_SET_FIELDS, SCM_UNPACK (src), SCM_UNPACK (mod), SCM_UNPACK (name), SCM_UNPACK (exp))
|
||||
|
||||
#define SCM_EXPANDED_TOPLEVEL_DEFINE_TYPE_NAME "toplevel-define"
|
||||
#define SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES \
|
||||
{ "src", "name", "exp", }
|
||||
{ "src", "mod", "name", "exp", }
|
||||
enum
|
||||
{
|
||||
SCM_EXPANDED_TOPLEVEL_DEFINE_SRC,
|
||||
SCM_EXPANDED_TOPLEVEL_DEFINE_MOD,
|
||||
SCM_EXPANDED_TOPLEVEL_DEFINE_NAME,
|
||||
SCM_EXPANDED_TOPLEVEL_DEFINE_EXP,
|
||||
SCM_NUM_EXPANDED_TOPLEVEL_DEFINE_FIELDS,
|
||||
};
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE(src, name, exp) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_DEFINE], 0, SCM_NUM_EXPANDED_TOPLEVEL_DEFINE_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (exp))
|
||||
#define SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE(src, mod, name, exp) \
|
||||
scm_c_make_struct (exp_vtables[SCM_EXPANDED_TOPLEVEL_DEFINE], 0, SCM_NUM_EXPANDED_TOPLEVEL_DEFINE_FIELDS, SCM_UNPACK (src), SCM_UNPACK (mod), SCM_UNPACK (name), SCM_UNPACK (exp))
|
||||
|
||||
#define SCM_EXPANDED_CONDITIONAL_TYPE_NAME "conditional"
|
||||
#define SCM_EXPANDED_CONDITIONAL_FIELD_NAMES \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue