From 3a373a0b802ee86308db78cba8696aa7b6cdf4df Mon Sep 17 00:00:00 2001 From: dos-reis Date: Fri, 23 Jul 2010 21:09:39 +0000 Subject: * interp/g-opt.boot (optBind): Check for dependencies in initializations in %bind expressions. * interp/g-util.boot (expandBind): The body of s %bind expression may be a sequence of statements. --- src/interp/g-opt.boot | 7 +++++-- src/interp/g-util.boot | 10 ++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/interp') diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 543cf45e..a42dc1ac 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -590,8 +590,11 @@ optLET_* form == optLET form optBind form == - form.first := "LET*" - optLET_* form + form isnt ['%bind,inits,body] => form -- inline only simple expressions + inits = nil => body -- no local variable, OK. + inits isnt [[var,expr]] => form -- too many local variables + canInlineVarDefinition(var,expr,body) => substitute(expr,var,body) + form optLIST form == form is ["LIST"] => nil diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index 5889fc2a..13acbdc6 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -305,16 +305,14 @@ expandFgt ['%fgt,x,y] == expandFlt ['%flt,y,x] -- Local variable bindings -expandBind ['%bind,inits,body] == +expandBind ['%bind,inits,:body] == body := expandToVMForm body inits := [[first x,expandToVMForm second x] for x in inits] - n := #inits - n = 0 => body -- FIXME: we should consider turning LET* into LET or direct inlining. op := - n = 1 => 'LET - 'LET_* - [op,inits,body] + or/[CONTAINED(v,x) for [[v,.],:x] in tails inits] => 'LET_* + 'LET + [op,inits,:body] -- Memory load/store -- cgit v1.2.3