summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/functions.c b/functions.c
index bc71fb9..37cafa1 100644
--- a/functions.c
+++ b/functions.c
@@ -126,8 +126,15 @@ Array *
runfunc(Function f, Array *left, Array *right)
{
Array *result;
- if(f.type == FunctypeDfn){
- pushdfnframe(f.dfn);
+ if(f.type == FunctypeDfn || (f.type == FunctypeOp && f.operator.type == OperatortypeDop)){
+ Rune *code;
+ if(f.type == FunctypeDfn)
+ code = f.dfn;
+ else{
+ code = f.operator.dop;
+ }
+
+ pushdfnframe(code);
if(left){
Symbol *alpha = getsym(L"⍺", 1);
alpha->value.tag = ArrayTag;
@@ -142,7 +149,17 @@ runfunc(Function f, Array *left, Array *right)
omega->undefined = 0;
incref(right);
- Datum *dfnres = evalline(f.dfn, nil, 0);
+ if(f.type == FunctypeOp){
+ if(f.operator.dyadic){
+ Symbol *omegaop = getsym(L"⍹", 1);
+ omegaop->value = *f.operator.right;
+ omegaop->undefined = 0;
+ }
+ Symbol *alphaop = getsym(L"⍶", 1);
+ alphaop->value = *f.operator.left;
+ alphaop->undefined = 0;
+ }
+ Datum *dfnres = evalline(code, nil, 0);
popdfnframe();
result = (*dfnres).array; /* TODO what if the evaluation failed */
}else if(f.type == FunctypePrim){