Skip to content

Commit d9a8199

Browse files
committed
More lookup tidying
1 parent 703927a commit d9a8199

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

convex-core/src/main/java/convex/core/lang/Context.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ private Address getParentAddress(AccountStatus as) {
639639
*/
640640
@SuppressWarnings("unchecked")
641641
public <T extends ACell> T lookupValue(String symName) {
642-
return (T) lookupValue(Symbol.create(symName));
642+
return (T) lookupValue(getAddress(),Symbol.create(symName));
643643
}
644644

645645
/**
@@ -648,17 +648,7 @@ public <T extends ACell> T lookupValue(String symName) {
648648
* @return Value for the given symbol or null if undeclared
649649
*/
650650
public ACell lookupValue(Symbol sym) {
651-
AHashMap<Symbol, ACell> env=getEnvironment();
652-
653-
// Lookup in current environment first
654-
MapEntry<Symbol,ACell> me=env.getEntry(sym);
655-
if (me!=null) {
656-
return me.getValue();
657-
}
658-
659-
AccountStatus as = getAliasedAccount(env);
660-
if (as==null) return null;
661-
return as.getEnvironment().get(sym);
651+
return lookupValue(getAddress(),sym);
662652
}
663653

664654
/**
@@ -668,11 +658,9 @@ public ACell lookupValue(Symbol sym) {
668658
* @return Value for the given symbol or null if undeclared
669659
*/
670660
public ACell lookupValue(Address address,Symbol sym) {
671-
if (address==null) return lookupValue(sym);
672-
AccountStatus as=getAccountStatus(address);
673-
if (as==null) return null;
674-
AHashMap<Symbol, ACell> env=as.getEnvironment();
675-
return env.get(sym);
661+
MapEntry<Symbol,ACell> entry=lookupDynamicEntry(address,sym);
662+
if (entry==null) return null;
663+
return entry.getValue();
676664
}
677665

678666
/**
@@ -683,6 +671,7 @@ public ACell lookupValue(Address address,Symbol sym) {
683671
* @return Environment entry
684672
*/
685673
public MapEntry<Symbol,ACell> lookupDynamicEntry(Address address,Symbol sym) {
674+
if (address==null) address=getAddress();
686675
AccountStatus as=getAccountStatus(address);
687676
if (as==null) return null;
688677
return lookupDynamicEntry(as,sym);

0 commit comments

Comments
 (0)