Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't short circuit eval_sexp on nodes which contain the special argument. #2942

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 22 additions & 19 deletions code/parse/sexp.cpp
Expand Up @@ -23094,29 +23094,32 @@ int eval_sexp(int cur_node, int referenced_node)
Assert( (type == SEXP_LIST) || (type == SEXP_ATOM) );

// trap known true and known false sexpressions. We don't trap on SEXP_NAN sexpressions since
// they may yet evaluate to true or false.
// they may yet evaluate to true or false. If the sexp depends on the special argument,
// we can't 'know' its value so we skip this behaviour.

// we want to log event values for KNOWN_X or FOREVER_X before returning
if (Log_event && ((Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) || (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) || (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER))) {
// if this is a node that has been assigned the value by short-circuiting,
// it might not be the operator that returned the value
int op_index = get_operator_index(cur_node);
if (op_index < 0)
op_index = get_operator_index(CAR(cur_node));
if (!special_argument_appears_in_sexp_tree(cur_node)) {
if (Log_event && ((Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) || (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) || (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER))) {
// if this is a node that has been assigned the value by short-circuiting,
// it might not be the operator that returned the value
int op_index = get_operator_index(cur_node);
if (op_index < 0)
op_index = get_operator_index(CAR(cur_node));

// log the known value
add_to_event_log_buffer(op_index, Sexp_nodes[cur_node].value);
}
// log the known value
add_to_event_log_buffer(op_index, Sexp_nodes[cur_node].value);
}

// now do a quick return whether or not we log, per the comment above about trapping known sexpressions
if (Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) {
return SEXP_TRUE;
}
else if (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) {
return SEXP_FALSE;
}
else if (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER) {
return SEXP_FALSE;
// now do a quick return whether or not we log, per the comment above about trapping known sexpressions
if (Sexp_nodes[cur_node].value == SEXP_KNOWN_TRUE) {
return SEXP_TRUE;
}
else if (Sexp_nodes[cur_node].value == SEXP_KNOWN_FALSE) {
return SEXP_FALSE;
}
else if (Sexp_nodes[cur_node].value == SEXP_NAN_FOREVER) {
return SEXP_FALSE;
}
}

if (Sexp_nodes[cur_node].first != -1) {
Expand Down