aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog7
-rw-r--r--src/algebra/array1.spad.pamphlet5
-rw-r--r--src/interp/g-opt.boot3
-rw-r--r--src/interp/lisp-backend.boot4
4 files changed, 18 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cb492b6d..02579bae 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * interp/g-opt.boot (%array2list): New side-effect free opcode.
+ * interp/lisp-backend.boot: Expand it.
+ * algebra/array1.spad.pamphlet (PrimitiveArray): Implement
+ maxIndex, parts, and members.
+
2013-05-12 Gabriel Dos Reis <gdr@integrable-solutions.net>
* algebra/vector.spad.pamphlet (IndexedVector): Remove.
diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet
index 9ace920a..ee4b913b 100644
--- a/src/algebra/array1.spad.pamphlet
+++ b/src/algebra/array1.spad.pamphlet
@@ -17,12 +17,14 @@
PrimitiveArray(S:Type): OneDimensionalArrayAggregate S == add
macro NNI == NonNegativeInteger
import %icst0: Integer from Foreign Builtin
+ import %icst1: Integer from Foreign Builtin
import %vlength: % -> NNI from Foreign Builtin
import %vcopy: % -> % from Foreign Builtin
import %vfill: (%,S) -> % from Foreign Builtin
import %aref: (%,Integer) -> S from Foreign Builtin
import %emptyArray: Type -> % from Foreign Builtin
import %list2array: (List S,Type) -> % from Foreign Builtin
+ import %array2list: % -> List S from Foreign Builtin
import %simpleArray: (Type,NNI,S) -> % from Foreign Builtin
#x == %vlength x
@@ -36,6 +38,9 @@ PrimitiveArray(S:Type): OneDimensionalArrayAggregate S == add
setelt(x:%, i:Integer, s:S) == %store(%aref(x,i),s)$Foreign(Builtin)
fill!(x, s) == %vfill(x,s)
copy x == %vcopy x
+ maxIndex x == #x - %icst1
+ parts x == %array2list x
+ members x == parts x
@
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 6e379d21..c65dcf2d 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -657,7 +657,8 @@ $VMsideEffectFreeOperators ==
%sname
%strlength %streq %i2s %schar %strlt %strconc
%strcopy %bytevec2str %str2bytevec
- %array %simpleArray %emptyArray %list2array %initialElement %initialContents
+ %array %simpleArray %emptyArray %list2array %array2list
+ %initialElement %initialContents
%vector %aref %vref %vlength %vcopy
%bitvector
%bitvecnot %bitvecand %bitvecnand %bivecor %bitvecnor %bitvecxor
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index 6fb119e8..d1fa2d74 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -190,6 +190,9 @@ expandList(x is ['%list,:args]) ==
args' = 'failed => ['LIST,:args]
quote args'
+expandArray2List ['%array2list,x] ==
+ ['COERCE,expandToVMForm x,quote 'LIST]
+
expandLeave ['%leave,l,x] ==
x := expandToVMForm x
l = nil => ['RETURN,x]
@@ -672,6 +675,7 @@ for x in [
++ Table of opcode-expander pairs.
for x in [
['%list, :function expandList],
+ ['%array2list, :function expandArray2List],
['%collect, :function expandCollect],
['%repeat, :function expandRepeat],
['%return, :function expandReturn],