Use string values instead of string pointers in Expression. (#591)

This commit is contained in:
Geoff Romer
2021-06-24 11:01:13 -07:00
committed by GitHub
parent 9bdabda851
commit 85cfb3b930
4 changed files with 32 additions and 35 deletions
@@ -624,10 +624,10 @@ void StepLvalue() {
// { {x :: C, E, F} :: S, H}
// -> { {E(x) :: C, E, F} :: S, H}
std::optional<Address> pointer =
CurrentEnv(state).Get(*(exp->GetVariable().name));
CurrentEnv(state).Get(exp->GetVariable().name);
if (!pointer) {
std::cerr << exp->line_num << ": could not find `"
<< *(exp->GetVariable().name) << "`" << std::endl;
<< exp->GetVariable().name << "`" << std::endl;
exit(-1);
}
const Value* v = Value::MakePtrVal(*pointer);
@@ -721,10 +721,10 @@ void StepExp() {
case ExpressionKind::Variable: {
// { {x :: C, E, F} :: S, H} -> { {H(E(x)) :: C, E, F} :: S, H}
std::optional<Address> pointer =
CurrentEnv(state).Get(*(exp->GetVariable().name));
CurrentEnv(state).Get(exp->GetVariable().name);
if (!pointer) {
std::cerr << exp->line_num << ": could not find `"
<< *(exp->GetVariable().name) << "`" << std::endl;
<< exp->GetVariable().name << "`" << std::endl;
exit(-1);
}
const Value* pointee = state->heap.Read(*pointer, exp->line_num);
@@ -1082,7 +1082,7 @@ void HandleValue() {
// -> { { &v.f :: C, E, F} :: S, H }
const Value* str = act->results[0];
Address a = GetMember(ValToPtr(str, exp->line_num),
*exp->GetFieldAccess().field, exp->line_num);
exp->GetFieldAccess().field, exp->line_num);
frame->todo.Pop(2);
frame->todo.Push(MakeValAct(Value::MakePtrVal(a)));
break;
@@ -1135,7 +1135,7 @@ void HandleValue() {
const Expression* exp = act->u.exp;
switch (exp->tag()) {
case ExpressionKind::PatternVariable: {
auto v = Value::MakeVarPatVal(*exp->GetPatternVariable().name,
auto v = Value::MakeVarPatVal(exp->GetPatternVariable().name,
act->results[0]);
frame->todo.Pop(2);
frame->todo.Push(MakeValAct(v));
@@ -1194,7 +1194,7 @@ void HandleValue() {
// { { v :: [].f :: C, E, F} :: S, H}
// -> { { v_f :: C, E, F} : S, H}
auto a = GetMember(ValToPtr(act->results[0], exp->line_num),
*exp->GetFieldAccess().field, exp->line_num);
exp->GetFieldAccess().field, exp->line_num);
const Value* element = state->heap.Read(a, exp->line_num);
frame->todo.Pop(2);
frame->todo.Push(MakeValAct(element));