mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 22:02:42 +01:00
Use string values instead of string pointers in Expression. (#591)
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user