Skip to content

Commit

Permalink
Support @ operator
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Oct 2, 2015
1 parent aea5b2d commit badd17b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ASTNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const char* ASTBinary::op_str() const
".", " ** ", " * ", " / ", " // ", " % ", " + ", " - ",
" << ", " >> ", " & ", " ^ ", " | ", " and ", " or ",
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
" >>= ", " &= ", " ^= ", " |= ", " //= "
" >>= ", " &= ", " ^= ", " |= ", " //= ", " @ ", " @= ",
};
return s_op_strings[op()];
}
Expand Down
2 changes: 1 addition & 1 deletion ASTNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ASTBinary : public ASTNode {
BIN_OR, BIN_LOG_AND, BIN_LOG_OR, BIN_IP_ADD, BIN_IP_SUBTRACT,
BIN_IP_MULTIPLY, BIN_IP_DIVIDE, BIN_IP_MODULO, BIN_IP_POWER,
BIN_IP_LSHIFT, BIN_IP_RSHIFT, BIN_IP_AND, BIN_IP_XOR, BIN_IP_OR,
BIN_IP_FLOOR,
BIN_IP_FLOOR, BIN_MAT_MULTIPLY, BIN_IP_MAT_MULTIPLY,
};

ASTBinary(PycRef<ASTNode> left, PycRef<ASTNode> right, int op,
Expand Down
17 changes: 17 additions & 0 deletions ASTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.push(new ASTBinary(left, right, ASTBinary::BIN_XOR));
}
break;
case Pyc::BINARY_MATRIX_MULTIPLY:
{
PycRef<ASTNode> right = stack.top();
stack.pop();
PycRef<ASTNode> left = stack.top();
stack.pop();
stack.push(new ASTBinary(left, right, ASTBinary::BIN_MAT_MULTIPLY));
}
case Pyc::BREAK_LOOP:
curblock->append(new ASTKeyword(ASTKeyword::KW_BREAK));
break;
Expand Down Expand Up @@ -906,6 +914,15 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.push(new ASTBinary(left, right, ASTBinary::BIN_IP_XOR));
}
break;
case Pyc::INPLACE_MATRIX_MULTIPLY:
{
PycRef<ASTNode> right = stack.top();
stack.pop();
PycRef<ASTNode> left = stack.top();
stack.pop();
stack.push(new ASTBinary(left, right, ASTBinary::BIN_IP_MAT_MULTIPLY));
}
break;
case Pyc::JUMP_IF_FALSE_A:
case Pyc::JUMP_IF_TRUE_A:
case Pyc::JUMP_IF_FALSE_OR_POP_A:
Expand Down
Binary file added tests/35_matrix_mult_oper.pyc
Binary file not shown.

0 comments on commit badd17b

Please sign in to comment.