diff options
author | dos-reis <gdr@axiomatics.org> | 2009-07-12 17:10:18 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2009-07-12 17:10:18 +0000 |
commit | 3838fe22164e91e9d5269f801c2b668682ccde83 (patch) | |
tree | 68200708174170f1d1ce3573e7d8cf77a4af4d81 /src | |
parent | 9a91238840354e46c0f1d898881d5ebf8c395520 (diff) | |
download | open-axiom-3838fe22164e91e9d5269f801c2b668682ccde83.tar.gz |
* algebra/mkfunc.spad.pamphlet
(mkDefun$MakeFloatCompiledFunction): Tidy.
* interp/c-util.boot (declareUnusedParameters): New.
* interp/i-map.boot: Use it.
* interp/i-spec1.boot: Likewise.
* interp/slam.boot: Likewise.
* lib/cfuns-c.c (writeablep): Document MinGW/MSYS bug work around.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 12 | ||||
-rw-r--r-- | src/algebra/mkfunc.spad.pamphlet | 16 | ||||
-rw-r--r-- | src/doc/help/library.help | 27 | ||||
-rw-r--r-- | src/input/torus.input.pamphlet | 2 | ||||
-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 | ||||
-rw-r--r-- | src/lib/cfuns-c.c | 7 |
9 files changed, 77 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 981cc7ec..cac7aa68 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,14 @@ -2009-07-10 Alfredo Portes <doyenatccny@gmail.com> +2009-07-12 Gabriel Dos Reis <gdr@cse.tamu.edu> + + * algebra/mkfunc.spad.pamphlet + (mkDefun$MakeFloatCompiledFunction): Tidy. + * interp/c-util.boot (declareUnusedParameters): New. + * interp/i-map.boot: Use it. + * interp/i-spec1.boot: Likewise. + * interp/slam.boot: Likewise. + * lib/cfuns-c.c (writeablep): Document MinGW/MSYS bug work around. + +2009-07-10 Alfredo Portes <doyenatccny@gmail.com> * lib/cfuns-c.c (writeablep): Use function LocalFree() in Windows instead of free(). diff --git a/src/algebra/mkfunc.spad.pamphlet b/src/algebra/mkfunc.spad.pamphlet index 4b629b78..30f219d6 100644 --- a/src/algebra/mkfunc.spad.pamphlet +++ b/src/algebra/mkfunc.spad.pamphlet @@ -397,6 +397,11 @@ MakeFloatCompiledFunction(S): Exports == Implementation where coerceToSF(f: INF): INF == gencode("COERCE",[f, quote getVMType(SF)$Foreign(Builtin)]) + -- return true if the form `x' is contained in `y' + contained?(x: INF, y: INF): Boolean == + atom? y => x = y + contained?(x, car y) or contained?(x, cdr y) + mkPretend form == convert([convert("pretend"::Symbol), form, lsf]$List(INF))@INF @@ -410,9 +415,14 @@ MakeFloatCompiledFunction(S): Exports == Implementation where mkDefun(s, lv) == name := convert(new()$Symbol)@INF - fun := convert([convert("DEFUN"::Symbol), name, convert lv, - gencode("DECLARE",[gencode("FLOAT",lv)]), - coerceToSF mkCTOR s]$List(INF))@INF + body := coerceToSF mkCTOR s + unusedParms := [ p for p in lv | not contained?(p,s)] + stmts := + null unusedParms => [body] + [gencode("DECLARE",[gencode("IGNORE", unusedParms)]),body] + stmts := concat(gencode("DECLARE",[gencode("FLOAT",lv)]), stmts) + header := [convert("DEFUN"::Symbol), name, convert lv] + fun := convert append(header,stmts) EVAL(fun)$Lisp if _$compileDontDefineFunctions$Lisp then COMPILE(name)$Lisp name diff --git a/src/doc/help/library.help b/src/doc/help/library.help index dc8cae84..4d12063d 100644 --- a/src/doc/help/library.help +++ b/src/doc/help/library.help @@ -20,19 +20,20 @@ Command Syntax: Command Description: -This command replaces the )load system command that was available in OpenAxiom -releases before version 2.0. The )library command makes available to OpenAxiom -the compiled objects in the libraries listed. - -For example, if you )compile dopler.as in your home directory, issue )library -dopler to have OpenAxiom look at the library, determine the category and domain -constructors present, update the internal database with various properties of -the constructors, and arrange for the constructors to be automatically loaded -when needed. If the )noexpose option has not been given, the constructors -will be exposed (that is, available) in the current frame. - -If you compiled a file with the old system compiler, you will have an NRLIB -present, for example, DOPLER.NRLIB, where DOPLER is a constructor +This command replaces the )load system command that was available in previous +releases. The )library command makes available to OpenAxiom the compiled +objects in the libraries listed. + +For example, if you )compile dopler.spad in your home directory, issue +)library dopler to have OpenAxiom look at the library, determine the +category and domain constructors present, update the internal database +with various properties of the constructors, and arrange for the +constructors to be automatically loaded when needed. If the )noexpose +option has not been given, the constructors will be exposed (that is, +available) in the current frame. + +If you compiled a file with the current system compiler, you will have an +NRLIB present, for example, DOPLER.NRLIB, where DOPLER is a constructor abbreviation. The command )library DOPLER will then do the analysis and database updates as above. diff --git a/src/input/torus.input.pamphlet b/src/input/torus.input.pamphlet index 81ea7b79..233a9bc1 100644 --- a/src/input/torus.input.pamphlet +++ b/src/input/torus.input.pamphlet @@ -12,7 +12,7 @@ <<*>>= )cl all f(x:SF):SF == x -torus : TUBE := tubePlot(sin t,cos t,0,f,0..2*%pi,0.5::SF,12,"closed") +torus := tubePlot(sin t,cos t,0,f,0..2*%pi,0.5::SF,12,"closed") makeViewport3D(torus,"torus")$VIEW3D @ \eject 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]] diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index 849af3c4..63758092 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -247,6 +247,13 @@ writeablep(char *path) is writable. */ char* dir = oa_dirname(path); code = stat(dir, &buf); + /* FIXME: Work around MinGW/MSYS bug. + The string pointed to by `dir' was strdup'd. According to + the C standard, that means the the string was allocated + by `malloc', therefore can be disposed of by `free'. However, + the MinGW/MSYS port appears to use MS' StrDup as the real + worker. Consequently, the guarantee that the the string can + free'd no longer holds. We have to use MS's LocalFree. */ #ifdef __WIN32__ LocalFree(dir); #else |