Skip to content

Commit 84a2747

Browse files
committed
Make compiler handle non-hashmap maps as constants
1 parent bbf11af commit 84a2747

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ static Context compile(ACell form, Context context) {
110110
if (form instanceof ADataStructure) {
111111
if (form instanceof AList) return compileList((AList<ACell>) form, context);
112112
if (form instanceof AVector) return compileVector((AVector<ACell>) form, context);
113-
if (form instanceof AMap) return compileMap((AMap<ACell, ACell>) form, context);
113+
if (form instanceof AHashMap) return compileMap((AHashMap<ACell, ACell>) form, context);
114114
if (form instanceof ASet) return compileSet((ASet<ACell>) form, context);
115+
if (form instanceof AMap) return compileConstant( context,form);
115116
return context.withCompileError("Unexpected data structure: "+form.getClass());
116117
}
117118

@@ -309,7 +310,7 @@ private static Context compileLookup(AList<ACell> list, Context context) {
309310
* @param context
310311
* @return Op producing the given map
311312
*/
312-
private static Context compileMap(AMap<ACell, ACell> form, Context context) {
313+
private static Context compileMap(AHashMap<ACell, ACell> form, Context context) {
313314
int n = form.size();
314315
if (n==0) return context.withResult(Juice.COMPILE_CONSTANT, Constant.EMPTY_MAP);
315316

@@ -801,7 +802,7 @@ public Context invoke(Context context,ACell[] args ) {
801802
return ctx.withResult(Juice.EXPAND_SEQUENCE, updated);
802803
}
803804

804-
if (form instanceof AMap) {
805+
if (form instanceof AHashMap) {
805806
Context ctx = context;
806807
AMap<ACell, ACell> updated = Maps.empty();
807808
for (Map.Entry<ACell, ACell> me : ((AMap<ACell, ACell>) form).entrySet()) {

0 commit comments

Comments
 (0)