1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-24 11:31:31 +00:00

Made a slight improvement in the ld65 expression evaluator.

This commit is contained in:
Greg King 2021-06-13 20:36:05 -04:00
parent 14d05c61b6
commit fcda94f258

View File

@ -321,20 +321,18 @@ long GetExprVal (ExprNode* Expr)
return GetExprVal (Expr->Left) * GetExprVal (Expr->Right); return GetExprVal (Expr->Left) * GetExprVal (Expr->Right);
case EXPR_DIV: case EXPR_DIV:
Left = GetExprVal (Expr->Left);
Right = GetExprVal (Expr->Right); Right = GetExprVal (Expr->Right);
if (Right == 0) { if (Right == 0) {
Error ("Division by zero"); Error ("Division by zero");
} }
return Left / Right; return GetExprVal (Expr->Left) / Right;
case EXPR_MOD: case EXPR_MOD:
Left = GetExprVal (Expr->Left);
Right = GetExprVal (Expr->Right); Right = GetExprVal (Expr->Right);
if (Right == 0) { if (Right == 0) {
Error ("Modulo operation with zero"); Error ("Modulo operation with zero");
} }
return Left % Right; return GetExprVal (Expr->Left) % Right;
case EXPR_OR: case EXPR_OR:
return GetExprVal (Expr->Left) | GetExprVal (Expr->Right); return GetExprVal (Expr->Left) | GetExprVal (Expr->Right);