aboutsummaryrefslogtreecommitdiff
path: root/compiler/standardClient.ey
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2014-03-18 18:26:14 +0100
committerDrahflow <drahflow@gmx.de>2014-03-18 18:26:14 +0100
commit0eaf7a0d0b0afd58ccaaad4b06aaa66c3e11ae9a (patch)
treebbfdc96a788b1ffd585f463005f085114b66cb44 /compiler/standardClient.ey
parentb4d11704aa33ec6d471479e60be0fdaade5d9b7d (diff)
Automatic scope-handling of global functions
Diffstat (limited to 'compiler/standardClient.ey')
-rw-r--r--compiler/standardClient.ey38
1 files changed, 32 insertions, 6 deletions
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index 4409100..d807533 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -380,6 +380,8 @@
} { enregex * } ? *
} /regex defq
+{ scope keys }' /globals deffd
+
< # sys extensions
# TODO: handle EINTR correctly
@@ -610,7 +612,7 @@
} /commonIterationType deff
{ ==arr
- arr sys .typed .type 7 eq { [ arr _ len dearray ] } { arr "#iclone" . } ? *
+ arr sys .typed .type 7 eq { 0 arr len range } { arr "#iclone" . } ? *
} /cloneForLoop deff
{ ==arr ==i
@@ -705,15 +707,39 @@
[ toBeAbstractedTypes { len } each ] any not {
# no types need to be abstracted, function can be called
- concreteArgs # _ dump
- _ len dearray f
# "attempting to call function (w.o. abstraction)" dump
- 0 concreteArgs len range { ==i
+ 0 ==typeMismatch
+ 0 ==mismatchIndex
+ 0 concreteArgs len range reverse { ==i
i concreteArgs * sys .typed .type # _ dump
i inputs * sys .typed .type # _ dump
- neq { "invalid input type at argument index " dump i dump "" die } rep
+ neq typeMismatch not and { 1 =typeMismatch i =mismatchIndex } rep
} each
- *
+ typeMismatch {
+ mismatchIndex concreteArgs * ==arg
+ arg sys .typed .type 9 eq { # this is a scope
+ "" ==handlingMember
+ globals { _ ==g | sys .asm .rawAddress f sys .asm .rawAddress eq {
+ mismatchIndex 9 gt { "cannot create member-fallback for argument index " dump mismatchIndex dump "" die } rep
+ arg
+ concreteArgs len 1 sub mismatchIndex sub [
+ "#" "#-01 " "#-021 " "#-0321 " "#-04321 " "#-054321 " "#-0654321 " "#-07654312 " "#-087654321 " "#-0987654321 "
+ ] *
+ g cat _ ==candidate .? { candidate =handlingMember } rep
+ } rep
+ } each
+ "" handlingMember eq { "a handling member could not be found at argument index " dump mismatchIndex dump "" die } rep
+ 0 concreteArgs len range { ==i
+ i mismatchIndex neq { i concreteArgs * } rep
+ } each
+ arg handlingMember .
+ } {
+ "invalid input type at argument index " dump typeMismatch 1 sub dump "" die
+ } ? *
+ } {
+ concreteArgs # _ dump
+ _ len dearray f *
+ } ? *
} {
[ ] ==argTypes # the type stack of the new function
[ ] ==stageCalls # which functions to call in each stage