aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-05-29 19:25:31 +0000
committerdos-reis <gdr@axiomatics.org>2010-05-29 19:25:31 +0000
commita31ebb2c1b71c66ac34ffb0c27e6d7188ffb0906 (patch)
tree493366bf01adb5685ddf3a2c599ff0aaf2eac239 /src
parentd983797f2d41c45fcf0679c7f4d1f90c1702ed2f (diff)
downloadopen-axiom-a31ebb2c1b71c66ac34ffb0c27e6d7188ffb0906.tar.gz
* interp/compiler.boot (getExternalSymbolMode): Allow Lisp as
foreign language. (checkExternalEntity): Likewise. (compSignatureImport): Likewise. Give foreign variables dummy values. * interp/c-util.boot (middleEndExpand): Handle %true and %false. * interp/g-util.boot (expandToVMForm): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/interp/c-util.boot2
-rw-r--r--src/interp/compiler.boot22
-rw-r--r--src/interp/g-util.boot6
4 files changed, 31 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ebd6ae0f..b9850970 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-29 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/compiler.boot (getExternalSymbolMode): Allow Lisp as
+ foreign language.
+ (checkExternalEntity): Likewise.
+ (compSignatureImport): Likewise. Give foreign variables dummy values.
+ * interp/c-util.boot (middleEndExpand): Handle %true and %false.
+ * interp/g-util.boot (expandToVMForm): Likewise.
+
2010-05-28 Gabriel Dos Reis <gdr@cs.tamu.edu>
Add support for 'property' builtin function.
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index 459ef90e..79e040b6 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -1075,6 +1075,8 @@ $middleEndMacroList ==
middleEndExpand: %Form -> %Form
middleEndExpand x ==
+ x = '%false => 'NIL
+ x = '%true => 'T
isAtomicForm x => x
[op,:args] := x
IDENTP op and (fun := getOpcodeExpander op) => apply(fun,x,nil)
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 9ee54315..6bad4fcb 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -1125,7 +1125,8 @@ compReturn(["return",x],m,e) ==
++ `op' supposedly designate an external entity with language linkage
++ `lang'. Return the mode of its local declaration (import).
getExternalSymbolMode(op,lang,e) ==
- lang = "Builtin" => "%Thing" -- for the time being
+ lang = 'Builtin => "%Thing" -- for the time being
+ lang = 'Lisp => "%Thing" -- for the time being
lang ~= "C" =>
stackAndThrow('"Sorry: %b Foreign %1b %d is invalid at the moment",[lang])
get(op,"%Lang",e) ~= lang =>
@@ -1369,9 +1370,9 @@ checkExternalEntity(id,type,lang,e) ==
get(id,"modemap",e) =>
stackAndThrow('"%1b already names exported operations in scope",[id])
-- We don't type check builtin declarations at the moment.
- lang = "Builtin" => id
+ lang = 'Builtin or lang = 'Lisp => id
-- Only functions are accepted at the moment. And all mentioned
- -- types must be those that are supported by the FFI.
+ -- types must be those that are supported by the FFI.
type' := checkExternalEntityType(type,e)
type' isnt [=bootDenotation "Mapping",:.] =>
stackAndThrow('"Signature for external entity must be a Mapping type",nil)
@@ -1393,19 +1394,24 @@ compSignatureImport: (%Form,%Mode,%Env) -> %Maybe %Triple
compSignatureImport(["%SignatureImport",id,type,home],m,e) ==
-- 1. Make sure we have the right syntax.
home isnt ["Foreign",:args] =>
- stackAndThrow('"signature import from be from a %1bp domain",["Foreign"])
+ stackAndThrow('"signature import must be from a %1bp domain",["Foreign"])
args isnt [lang] =>
stackAndThrow('"%1bp takes exactly one argument",["Foreign"])
not IDENTP lang =>
stackAndThrow('"Argument to %1bp must be an identifier",["Foreign"])
- not (lang in '(Builtin C)) =>
+ not (lang in '(Builtin C Lisp)) =>
stackAndThrow('"Sorry: Only %1bp is valid at the moment",["Foreign C"])
-- 2. Make sure this import is not subverting anything we know
id' := checkExternalEntity(id,type,lang,e)
-- 3. Make a local declaration for it.
- T := compMakeDeclaration(id,removeModifiers type,e) or return nil
- T.env := put(id,"%Lang",lang,T.env)
- T.env:= put(id,"%Link",id',T.env)
+ T := [.,.,e] := compMakeDeclaration(id,removeModifiers type,e) or return nil
+ e := put(id,"%Lang",lang,e)
+ e := put(id,"%Link",id',e)
+ -- 4. Also make non-function externals self-evaluating so we don't
+ -- complain later for undefined variable references.
+ if T.mode isnt ['Mapping,:.] then
+ e := put(id,"value",[id',T.mode,nil],e)
+ T.env := e
convert(T,m)
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index 2ab9d696..0a78b182 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -253,6 +253,9 @@ expandIadd ["%iadd",:args] ==
expandIsub ["%isub",:args] ==
["-",:expandToVMForm args]
+expandEq ["%eq",:args] ==
+ ["EQ",:expandToVMForm args]
+
expandIeq ["%ieq",:args] ==
["EQL",:expandToVMForm args]
@@ -315,6 +318,7 @@ for x in [
["%imax",:function expandImax],
["%igcd",:function expandIgcd],
+ ["%eq",:function expandEq],
["%ieq",:function expandIeq],
["%head",:function expandHead],
@@ -332,6 +336,8 @@ getOpcodeExpander op ==
++ Expand all opcodes contained in the form `x' into a form
++ suitable for evaluation by the VM.
expandToVMForm x ==
+ x = '%false => 'NIL
+ x = '%true => 'T
isAtomicForm x => x
[op,:args] := x
IDENTP op and (fun:= getOpcodeExpander op) => apply(fun,x,nil)