Skip to content

Commit

Permalink
Implement __matmul__ method with @ operator
Browse files Browse the repository at this point in the history
  • Loading branch information
graceynichols committed Jun 24, 2019
1 parent 7264ca7 commit 82e03b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Sk.abstr.boNameToSlotFuncLhs_ = function (obj, name) {
return obj.nb$subtract ? obj.nb$subtract : obj["__sub__"];
case "Mult":
return obj.nb$multiply ? obj.nb$multiply : obj["__mul__"];
case "MatMult":
return obj.tp$matmul ? obj.tp$matmul : obj["__matmul__"];
case "Div":
return obj.nb$divide ? obj.nb$divide : obj["__div__"];
case "FloorDiv":
Expand Down
3 changes: 3 additions & 0 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ var operatorMap = {};
operatorMap[TOK.T_PLUS] = Sk.astnodes.Add;
operatorMap[TOK.T_MINUS] = Sk.astnodes.Sub;
operatorMap[TOK.T_STAR] = Sk.astnodes.Mult;
operatorMap[TOK.T_AT] = Sk.astnodes.MatMult;
operatorMap[TOK.T_SLASH] = Sk.astnodes.Div;
operatorMap[TOK.T_DOUBLESLASH] = Sk.astnodes.FloorDiv;
operatorMap[TOK.T_PERCENT] = Sk.astnodes.Mod;
Expand Down Expand Up @@ -2019,6 +2020,8 @@ function astForAugassign (c, n) {
return Sk.astnodes.Pow;
}
return Sk.astnodes.Mult;
case "@":
return Sk.astnodes.MatMult;
default:
Sk.asserts.fail("invalid augassign");
}
Expand Down
1 change: 1 addition & 0 deletions src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Sk.dunderToSkulpt = {
"__gt__": "ob$gt",
"__ge__": "ob$ge",
"__hash__": "tp$hash",
"__matmul__": "tp$matmul",
"__abs__": "nb$abs",
"__neg__": "nb$negative",
"__pos__": "nb$positive",
Expand Down

0 comments on commit 82e03b8

Please sign in to comment.