aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2014-03-11 19:41:09 +0100
committerDrahflow <drahflow@gmx.de>2014-03-11 19:41:09 +0100
commitb4d11704aa33ec6d471479e60be0fdaade5d9b7d (patch)
tree07e1c5e0c43b8d3421f14c0adea77c769d6ccdfd
parent322d8de9f2d5a4b7159c72d36add03e29dcbe5c2 (diff)
Complex data types can now be done
-rw-r--r--compiler/standardClient.ey31
-rw-r--r--elymas/lib/sys/opt.ey8
-rw-r--r--examples/working-compiler/mapping.test27
-rw-r--r--examples/working-loaded/mapping.test37
4 files changed, 65 insertions, 38 deletions
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index cdf2f6f..4409100 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -527,6 +527,15 @@
invalid # function type
{
[
+ { object "#dom" .? } {
+ object "#dom" . ==d
+ object "#in" . ==in
+ in len 1 neq { "multi-input scope (with #dom) in typeStack" die } rep
+ [ 0 in * 0 d len 1 sub ]
+ object "#out" . ==out
+ out len 1 neq { "multi-output scope (with #dom) in typeStack" die } rep
+ 0 out * typeStackInternal
+ }
{ object "#*" .? } {
object "#in" . ==in
in len 1 neq { "multi-input scope in typeStack" die } rep
@@ -601,15 +610,23 @@
} /commonIterationType deff
{ ==arr
- 0
+ arr sys .typed .type 7 eq { [ arr _ len dearray ] } { arr "#iclone" . } ? *
+ } /cloneForLoop deff
+
+ { ==arr ==i
+ arr sys .typed .type 7 eq { i } { i arr "#itrans" . } ? *
+ } /transformLoopIndex deff
+
+ { ==arr
+ arr sys .typed .type 7 eq { 0 } { arr "#istart" . } ? *
} /getLoopStart deff
{ ==arr
- arr len eq
+ arr sys .typed .type 7 eq { arr len eq } { arr "#iend" . } ? *
} /isLoopEnd deff
{ ==arr
- 1 add
+ arr sys .typed .type 7 eq { 1 add } { arr "#istep" . } ? *
} /doLoopStep deff
# Executing a function f: A->B->C (i.e. B A f) on concrete arguments b a.
@@ -751,18 +768,18 @@
[ argTypes _ len dearray ==argType ] =argTypes
[ loops _ len dearray ==loopIndex ] =loops
loopIndex 0 ge {
- [ ] ==results
loopIndex concreteArgs * ==loopedOver
+ loopedOver cloneForLoop ==results
loopedOver getLoopStart ==i
{ i loopedOver isLoopEnd not } {
[ concreteArgs _ len dearray ] ==concreteArgsCopy
stage { ==j
# TODO: think about a single function returning multiple values
- i j concreteArgs * * j concreteArgsCopy =[]
+ i loopedOver transformLoopIndex j concreteArgs * * j concreteArgsCopy =[]
} each
- [ concreteArgsCopy stageCalls argTypes loops unravel ]
- results -01 cat =results
+ concreteArgsCopy stageCalls argTypes loops unravel
+ i loopedOver transformLoopIndex results =[]
# results dump
# TODO: think about a single function returning multiple values
# should be solved by producing two arrays side by side
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index f1dd509..4229748 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -435,8 +435,8 @@
{
[ STRINGSTAR ] i logic =[]
}
- { "failed to optimize 'execution' of scope typed object" die }
- { "failed to optimize 'execution' of name table" die }
+ { "failed to optimize 'execution' of float typed object" die }
+ { "objects of type 3 should not appear" die }
{ "failed to optimize 'execution' of extension area" die }
{
# TODO think about handling typed functions
@@ -455,8 +455,8 @@
[ ARRAYSTAR ] i logic =[]
}
{ "failed to optimize 'execution' of function type descriptor" die }
- { "objects of type 09 should not appear" die }
- { "objects of type 10 should not appear" die }
+ { } # TODO optimize scope execution one day
+ { "failed to optimize 'execution' of name table" die }
{ "objects of type 11 should not appear" die }
{ "objects of type 12 should not appear" die }
{ "objects of type 13 should not appear" die }
diff --git a/examples/working-compiler/mapping.test b/examples/working-compiler/mapping.test
deleted file mode 100644
index cf25036..0000000
--- a/examples/working-compiler/mapping.test
+++ /dev/null
@@ -1,27 +0,0 @@
-<
- { .v -01 . } "#*" defmd
- { -- [ 0 ] } "#in" defmd
- { -- [ 0 ] } "#out" defmd
- { .v keys } "#dom" defmd
- { .v ==v =*f v keys { v -01 . f } each } "#each" defmd
- { < < { defv }' > ==v "#=[]" =* > }
-> -- /map deffd
-
-map ==m
-
-0 "foo" m =[]
-1 "bar" m =[]
-2 "quux" m =[]
-
-"foo" m * dump
-"bar" m * dump
-"quux" m * dump
-
-m dom dump
-m { dump } each
-
-5 m mul ==mm
-
-"foo" mm * dump
-"bar" mm * dump
-"quux" mm * dump
diff --git a/examples/working-loaded/mapping.test b/examples/working-loaded/mapping.test
new file mode 100644
index 0000000..89bed82
--- /dev/null
+++ b/examples/working-loaded/mapping.test
@@ -0,0 +1,37 @@
+<
+ { .v -01 . } "#*" defmd
+ { [ 0 ] } "#in" deffd
+ { [ 0 ] } "#out" deffd
+ { .v keys } "#dom" defmd
+ { .v ==v =*f v keys { v -01 . f } each } "#each" defmd
+ { 0 } "#istart" deffd
+ { .v keys len eq } "#iend" defmd
+ { 1 add } "#istep" deffd
+ { .v keys * } "#itrans" defmd
+ { < < { defv }' > ==v "#=[]" =* > } _ "#iclone" deffd
+> -- /map deffd
+
+{ map } "(" deffd
+{ } ")" deffd
+{ -2102 =[] } "=>" deffd
+
+(
+ 0 =>foo
+ 1 =>bar
+ 2 =>quux
+) ==m
+
+{ _ ==m dom {
+ _ ": " cat -01 m * txt .produce .u cat dump
+ } each
+} /mdump deffd
+
+"foo" m * dump
+"bar" m * dump
+"quux" m * dump
+
+m mdump
+
+5 m add ==mm
+
+mm mdump