[Nice-commit] Nice/src/nice/tools/visibility tests.nice,1.2,1.3 impl.nice,1.1,1.2
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-06 15:52:16
|
Update of /cvsroot/nice/Nice/src/nice/tools/visibility In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1884/src/nice/tools/visibility Modified Files: tests.nice impl.nice Log Message: Put 'general' symbols at the highest possible level so their are viewed globally. Index: impl.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/visibility/impl.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** impl.nice 6 Mar 2005 12:55:56 -0000 1.1 --- impl.nice 6 Mar 2005 15:52:07 -0000 1.2 *************** *** 20,24 **** private <Sym> ?List<Sym> maybeGet(?Scope<Sym> s, String key) = ! s == null ? null : s.map[key]; add(Scope this, key, value, visibility) = map.add(key, value); --- 20,24 ---- private <Sym> ?List<Sym> maybeGet(?Scope<Sym> s, String key) = ! s == null ? null : (s.map[key] || s.opens[key] || s.parent.maybeGet(key)); add(Scope this, key, value, visibility) = map.add(key, value); *************** *** 31,36 **** add(Scope this, key, value, general) { ! super; ! publicMap.add(key, value); } --- 31,44 ---- add(Scope this, key, value, general) { ! // Put the symbol at the highest possible level ! if (parent != null) ! notNull(parent).add(key, value, general); ! else ! { ! // General implies familial ! this.add(key, value, familial); ! ! publicMap.add(key, value); ! } } *************** *** 45,49 **** <Sym> get(Scope this, root, key) = this.getScope(root).maybeGet(key) || empty; ! <Sym> get(Scope this, key) = map[key] || parent.maybeGet(key) || opens[key] || empty; <Sym> ?List<Sym> get(List<Scope<Sym>> scopes, String key) --- 53,57 ---- <Sym> get(Scope this, root, key) = this.getScope(root).maybeGet(key) || empty; ! <Sym> get(Scope this, key) = this.maybeGet(key) || empty; <Sym> ?List<Sym> get(List<Scope<Sym>> scopes, String key) Index: tests.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/visibility/tests.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tests.nice 6 Mar 2005 13:28:11 -0000 1.2 --- tests.nice 6 Mar 2005 15:52:07 -0000 1.3 *************** *** 201,204 **** --- 201,235 ---- } + void _testNestedVisibility() + { + Scope<char> root1 = new Scope(name: "root1", parent: null); + Scope<char> inner1 = new Scope(name: "inner1", parent: root1); + + Scope<char> root2 = new Scope(name: "root2", parent: null); + Scope<char> inner2 = new Scope(name: "inner2", parent: root2); + + root2.addImplicitOpen(root1); + + List<char> res; + + inner1.add("i", 'i', intimate); + res = inner2.get("i"); + assert res.size == 0; + res = root2.get("i"); + assert res.size == 0; + + inner1.add("f", 'f', familial); + res = inner2.get("f"); + assert res.size == 0; + res = root2.get("f"); + assert res.size == 0; + + inner1.add("g", 'g', general); + res = inner2.get("g"); + assert res.size == 1 && res[0] == 'g'; + res = root2.get("g"); + assert res.size == 1 && res[0] == 'g'; + } + void _testGeneralVisibility() { |