diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-21 16:05:41 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-21 16:05:41 +0000 |
commit | 80ebae7887e21f58ef09a18515e5521c5162053c (patch) | |
tree | 6b62ff6497d44fc9fe5c05b9a92a65cf2efee386 /eval.c | |
parent | e12450d52dce2d6271d12720bf18175d082a0003 (diff) |
Get ready for hybrids
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -22,8 +22,8 @@ Datum *lookup(Datum); int bindingstrengths[11][11] = { /* A F H MO DO AF ( ) ← IS N */ - 6, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, /* A */ - 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, /* F */ + 6, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, /* A */ + 2, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, /* F */ 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, /* H */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */ 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */ @@ -37,8 +37,8 @@ int bindingstrengths[11][11] = { evalfn evalfns[11][11] = { /* A F H MO DO AF ( ) ← IS N */ - strand, dyadfun, 0, monadop, 0, 0, 0, 0, 0, 0, 0, /* A */ - monadfun, 0, 0, monadop, 0, 0, 0, 0, 0, 0, 0, /* F */ + strand, dyadfun, dyadfun, monadop, 0, 0, 0, 0, 0, 0, 0, /* A */ + monadfun, 0, monadop, monadop, 0, 0, 0, 0, 0, 0, 0, /* F */ 0, 0, 0, monadop, 0, 0, 0, 0, 0, 0, 0, /* H */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* MO */ dyadop, dyadop, dyadop, 0, 0, 0, 0, 0, 0, 0, 0, /* DO */ @@ -192,8 +192,13 @@ dyadfun(Datum left, Datum right) traceprint("Applying left argument to function\n"); Datum result; result.shy = 0; - result.tag = BoundFunctionTag, - result.func = right.func; + result.tag = BoundFunctionTag; + if(right.tag == FunctionTag) + result.func = right.func; + else if(right.tag == HybridTag){ + result.func.type = FunctypeHybrid; + result.func.code = right.hybrid; + } result.func.left = left.array; incref(left.array); return result; @@ -256,7 +261,12 @@ monadop(Datum left, Datum right) result.shy = 0; result.tag = FunctionTag, result.func.type = FunctypeOp; - result.func.operator = right.operator; + if(right.tag == MonadicOpTag || right.tag == DyadicOpTag) + result.func.operator = right.operator; + else{ + result.func.operator.type = OperatortypeHybrid; + result.func.operator.code = right.hybrid; + } result.func.operator.left = arg; result.func.left = nil; if(arg->tag == ArrayTag) |