summaryrefslogtreecommitdiff
path: root/libguile/expand.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2019-08-16 09:08:43 +0200
committerAndy Wingo <wingo@pobox.com>2019-08-18 22:27:12 +0200
commit79a40cf717e62f45232979d1952f748ca42f8e8f (patch)
treed315f7a4796d7061aa48870ea01b72b878ea527c /libguile/expand.c
parent4bb5834d754aac50ba3288b232ea49f22cf21d0e (diff)
downloadguile-79a40cf717e62f45232979d1952f748ca42f8e8f.tar.gz
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.
Diffstat (limited to 'libguile/expand.c')
-rw-r--r--libguile/expand.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libguile/expand.c b/libguile/expand.c
index dd6eab0fe..11e43c2b9 100644
--- a/libguile/expand.c
+++ b/libguile/expand.c
@@ -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));