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

fix problematic env stray variable #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
macosbuild:
runs-on: macos-11
runs-on: macos-12
steps:
# Force xmake to a specific folder (for cache)
- name: Set xmake global dir
Expand Down
16 changes: 8 additions & 8 deletions moebius/drd/drd_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ drd_info_rep::get_env_child (tree t, int i, tree env) {

tag_info ti = info[L (t)];
int index= ti->get_index (i, N (t));
if ((index < 0) || (index >= N (ti->ci))) return "";
if ((index < 0) || (index >= N (ti->ci))) return tree (ATTR);
tree cenv= drd_decode (ti->ci[index].env);
for (int i= 1; i < N (cenv); i+= 2)
if (is_func (cenv[i], ARG, 1) && is_int (cenv[i][0])) {
Expand All @@ -787,7 +787,7 @@ drd_info_rep::get_env_descendant (tree t, path p, tree env) {
path q= p->next;
if (is_compound (t) && i >= 0 && i < N (t))
return get_env_descendant (t[i], q, get_env_child (t, i, env));
return "";
return tree (ATTR);
}

tree
Expand All @@ -813,7 +813,7 @@ tree
drd_info_rep::arg_access (tree t, tree arg, tree env, int& type, bool& found) {
// returns "" if unaccessible and the env if accessible
// cout << " arg_access " << t << ", " << arg << ", " << env << "\n";
if (is_atomic (t)) return "";
if (is_atomic (t)) return tree (ATTR);
else if (t == arg) {
found= true;
return env;
Expand All @@ -822,19 +822,19 @@ drd_info_rep::arg_access (tree t, tree arg, tree env, int& type, bool& found) {
return env;
else if (is_func (t, MAP_ARGS) && (t[2] == arg[0])) {
if ((N (t) >= 4) && (N (arg) >= 2) && (as_int (t[3]) > as_int (arg[1])))
return "";
return tree (ATTR);
if ((N (t) == 5) && (N (arg) >= 2) && (as_int (t[3]) <= as_int (arg[1])))
return "";
return tree (ATTR);
tree_label inner= make_tree_label (as_string (t[0]));
tree_label outer= make_tree_label (as_string (t[1]));
if (get_nr_indices (inner) > 0) type= get_type_child (tree (inner, arg), 0);
if ((get_nr_indices (inner) > 0) &&
(get_accessible (inner, 0) == ACCESSIBLE_ALWAYS) &&
all_accessible (outer))
return env;
return "";
return tree (ATTR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么用ATTR这个标记?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来的空字符串会变成什么?为什么会造成问题?

}
else if (is_func (t, MACRO)) return "";
else if (is_func (t, MACRO)) return tree (ATTR);
else if (is_func (t, WITH)) {
int n= N (t) - 1;
// cout << "env= " << drd_env_merge (env, t (0, n)) << "\n";
Expand Down Expand Up @@ -876,7 +876,7 @@ drd_info_rep::arg_access (tree t, tree arg, tree env, int& type, bool& found) {
// cout << " found type " << t << ", " << arg << ", " << type << "\n";
}
}
return "";
return tree (ATTR);
}
}

Expand Down
27 changes: 27 additions & 0 deletions tests/moebius/drd/drd_info_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** \file drd_info_test.cpp
* \copyright GPLv3
* \details Unitests for drd data structure
* \author jingkaimori
* \date 2024
*/

#include "moe_doctests.hpp"
#include "moebius/drd/drd_info.hpp"
#include "tree_helper.hpp"

using namespace moebius;

using moebius::drd::drd_info;

TEST_CASE ("drd initialize macro") {
drd_info test_drd ("test");
test_drd->heuristic_init_macro (
"test-macro",
tree (MACRO, "arg1", "arg2",
tree (CONCAT, tree (ARG, "arg1"), " text ", tree (ARG, "arg2"))));
tree_label test_macro_label= make_tree_label ("test-macro");
CHECK_EQ (test_drd->get_arity_base (test_macro_label), 2);
CHECK_EQ (test_drd->get_arity_extra (test_macro_label), 0);
CHECK_EQ (test_drd->get_arity_mode (test_macro_label), ARITY_NORMAL);
CHECK_EQ (test_drd->get_nr_indices (test_macro_label), 2);
}
2 changes: 1 addition & 1 deletion xmake/packages/l/lolly/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package("lolly")

add_urls("https://github.com/XmacsLabs/lolly.git")
add_urls("https://gitee.com/XmacsLabs/lolly.git")
add_versions("1.4.26", "v1.4.26")
add_versions("1.4.25", "v1.4.25")

add_deps("tbox")
if not is_plat("wasm") then
Expand Down
Loading