Migrate PrimitiveOperator to value semantics (#606)

* Make PrimitiveOperator.arguments a value.
* Make operator factory functions take Expressions by value.
This commit is contained in:
Geoff Romer
2021-06-28 15:58:32 -07:00
committed by GitHub
parent 276880ae83
commit 056da4dd5c
5 changed files with 42 additions and 45 deletions
@@ -746,11 +746,11 @@ void StepExp() {
frame->todo.Push(MakeValAct(Value::MakeBoolVal(exp->GetBoolean())));
break;
case ExpressionKind::PrimitiveOp:
if (exp->GetPrimitiveOperator().arguments->size() > 0) {
if (exp->GetPrimitiveOperator().arguments.size() > 0) {
// { {op(e :: es) :: C, E, F} :: S, H}
// -> { e :: op([] :: es) :: C, E, F} :: S, H}
frame->todo.Push(
MakeExpAct(exp->GetPrimitiveOperator().arguments->front()));
MakeExpAct(&exp->GetPrimitiveOperator().arguments.front()));
act->pos++;
} else {
// { {v :: op(]) :: C, E, F} :: S, H}
@@ -1205,11 +1205,11 @@ void HandleValue() {
}
case ExpressionKind::PrimitiveOp: {
if (act->pos !=
static_cast<int>(exp->GetPrimitiveOperator().arguments->size())) {
static_cast<int>(exp->GetPrimitiveOperator().arguments.size())) {
// { {v :: op(vs,[],e,es) :: C, E, F} :: S, H}
// -> { {e :: op(vs,v,[],es) :: C, E, F} :: S, H}
const Expression* arg =
(*exp->GetPrimitiveOperator().arguments)[act->pos];
&exp->GetPrimitiveOperator().arguments[act->pos];
frame->todo.Pop(1);
frame->todo.Push(MakeExpAct(arg));
} else {