diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/c-util.boot | 8 | ||||
-rw-r--r-- | src/interp/i-map.boot | 6 | ||||
-rw-r--r-- | src/interp/i-spec1.boot | 15 | ||||
-rw-r--r-- | src/interp/slam.boot | 16 |
4 files changed, 31 insertions, 14 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index 945ac812..3d050c51 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -41,6 +41,7 @@ module c_-util where replaceSimpleFunctions: %Form -> %Form foldExportedFunctionReferences: %List -> %List diagnoseUnknownType: (%Mode,%Env) -> %Form + declareUnusedParameters: (%List,%Code) -> %List --% @@ -121,6 +122,13 @@ wantArgumentsAsTuple: (%List,%Signature) -> %Boolean wantArgumentsAsTuple(args,sig) == isHomoegenousVarargSignature sig and #args ^= #sig +++ We are about to seal the (Lisp) definition of a function. +++ Augment the `body' with a declaration for those `parms' +++ that are unused. +declareUnusedParameters(parms,body) == + unused := [p for p in parms | not CONTAINED(p,body)] + null unused => [body] + [["DECLARE",["IGNORE",:unused]],body] devaluate d == not REFVECP d => d diff --git a/src/interp/i-map.boot b/src/interp/i-map.boot index 2199f298..d0969c48 100644 --- a/src/interp/i-map.boot +++ b/src/interp/i-map.boot @@ -1,6 +1,6 @@ -- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. -- All rights reserved. --- Copyright (C) 2007-2008, Gabriel Dos Reis. +-- Copyright (C) 2007-2009, Gabriel Dos Reis. -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -758,10 +758,10 @@ compileCoerceMap(op,argTypes,mm) == parms:= [:parms,'envArg] body := ['SPADCALL,:argCode,['LIST,['function,imp]]] minivectorName := makeInternalMapMinivectorName(name) - body := substitute(minivectorName,"$$$",body) + body := declareUnusedParameters(parms,substitute(minivectorName,"$$$",body)) setDynamicBinding(minivectorName,LIST2VEC $minivector) compileInteractive - [name,['LAMBDA,parms,declareGlobalVariables [minivectorName],body]] + [name,['LAMBDA,parms,declareGlobalVariables [minivectorName],:body]] CAR sig depthOfRecursion(opName,body) == diff --git a/src/interp/i-spec1.boot b/src/interp/i-spec1.boot index 46416212..2ef75f07 100644 --- a/src/interp/i-spec1.boot +++ b/src/interp/i-spec1.boot @@ -176,9 +176,11 @@ compileADEFBody(t,vars,types,body,computedResultType) == -- Dx: LODO(EXPR INT, f +-> D(f, x)) := D() -- -- MCD 13/3/96 + parms := [:vars,"envArg"] if not $definingMap and ($genValue or $compilingMap) then - fun := [$mapName,["LAMBDA",[:vars,'envArg], - declareGlobalVariables [minivectorName],body]] + fun := [$mapName,["LAMBDA",parms, + declareGlobalVariables [minivectorName], + :declareUnusedParameters(parms,body)]] code := wrap compileInteractive fun else $freeVariables := [] @@ -186,7 +188,8 @@ compileADEFBody(t,vars,types,body,computedResultType) == -- CCL does not support upwards funargs, so we check for any free variables -- and pass them into the lambda as part of envArg. body := checkForFreeVariables(body,"ALL") - fun := ["function",["LAMBDA",[:vars,'envArg],body]] + fun := ["function",["LAMBDA",parms, + :declareUnusedParameters(parms,body)]] code := ["CONS", fun, ["VECTOR", :reverse $freeVariables]] val := objNew(code,rt := ['Mapping,computedResultType,:rest types]) @@ -784,7 +787,8 @@ mkIterFun([index,:s],funBody,$localVars) == -- CCL does not support upwards funargs, so we check for any free variables -- and pass them into the lambda as part of envArg. body := checkForFreeVariables(getValue funBody,$localVars) - val:=['function,['LAMBDA,[index,'envArg],objVal body]] + parms := [index,"envArg"] + val:=['function,['LAMBDA,parms,:declareUnusedParameters(parms,objVal body)]] vec := mkAtreeNode GENSYM() putValue(vec,objNew(['CONS,val,["VECTOR",:reverse $freeVariables]],mapMode)) vec @@ -922,7 +926,8 @@ mkIterZippedFun(indexList,funBody,zipType,$localVars) == -- and pass them into the lambda as part of envArg. body := [checkForFreeVariables(form,$localVars) for form in getValue funBody] - val:=['function,['LAMBDA,[$index,'envArg],objVal body]] + parms := [$index,'envArg] + val:=['function,['LAMBDA,parms,:declareUnusedParameters(parms,objVal body)]] vec := mkAtreeNode GENSYM() putValue(vec,objNew(['CONS,val,["VECTOR",:reverse $freeVariables]],mapMode)) vec diff --git a/src/interp/slam.boot b/src/interp/slam.boot index 9e950e61..9340fe96 100644 --- a/src/interp/slam.boot +++ b/src/interp/slam.boot @@ -1,6 +1,6 @@ -- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. -- All rights reserved. --- Copyright (C) 2007-2008, Gabriel Dos Reis. +-- Copyright (C) 2007-2009, Gabriel Dos Reis. -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -53,9 +53,10 @@ reportFunctionCompilation(op,nam,argl,body,isRecursive) == init => compileRecurrenceRelation(op,nam,argl,body,init) cacheCount:= getCacheCount op cacheCount = "all" => reportFunctionCacheAll(op,nam,argl,body) + parms := [:argl,"envArg"] cacheCount = 0 or null argl => - fun:= [nam,["LAMBDA",[:argl,'envArg], - declareGlobalVariables [minivectorName],body]] + fun:= [nam,["LAMBDA",parms,declareGlobalVariables [minivectorName], + :declareUnusedParameters(parms,body)]] compileInteractive fun nam num := @@ -92,7 +93,8 @@ reportFunctionCompilation(op,nam,argl,body,isRecursive) == -- of above. lamex:= ["LAM",arg,codeBody] mainFunction:= [nam,lamex] - computeFunction:= [auxfn,["LAMBDA",[:argl, 'envArg],body]] + computeFunction:= [auxfn,["LAMBDA",parms, + :declareUnusedParameters(parms,body)]] compileInteractive mainFunction compileInteractive computeFunction cacheType:= "function" @@ -125,7 +127,9 @@ reportFunctionCacheAll(op,nam,argl,body) == codeBody:= ["PROG",[g2],["RETURN",["COND",secondPredPair,thirdPredPair]]] lamex:= ["LAM",arg,codeBody] mainFunction:= [nam,lamex] - computeFunction:= [auxfn,["LAMBDA",[:argl, 'envArg],body]] + parms := [:argl, "envArg"] + computeFunction:= [auxfn,["LAMBDA",parms, + :declareUnusedParameters(parms,body)]] compileInteractive mainFunction compileInteractive computeFunction cacheType:= 'hash_-table @@ -203,7 +207,7 @@ compileRecurrenceRelation(op,nam,argl,junk,[body,sharpArg,n,:initCode]) == continueInit:= [["%LET",gIndex,["%ELT",stateVar,0]], :[["%LET",g,["%ELT",stateVar,i]] for g in gsList for i in 1..]] - mainFunction:= [nam,["LAM",margl,mbody]] where + mainFunction:= [nam,["LAM",margl,:declareUnusedParameters(margl,mbody)]] where margl:= [:argl,'envArg] max:= GENSYM() tripleCode := ["CONS",n,["LIST",:initCode]] |