comparison core/src/luan/LuanState.java @ 433:c6bcb8859b93

make LuanState.registry a Map; remove generics from DeepCloneable; add Map support to DeepCloner;
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 May 2015 15:45:39 -0600
parents f28320fd671d
children bf5e62a9090c
comparison
equal deleted inserted replaced
432:d9df6d6cb927 433:c6bcb8859b93
1 package luan; 1 package luan;
2 2
3 import java.util.List; 3 import java.util.List;
4 import java.util.ArrayList; 4 import java.util.ArrayList;
5 import java.util.Map;
6 import java.util.HashMap;
5 import luan.impl.LuanCompiler; 7 import luan.impl.LuanCompiler;
6 import luan.modules.BasicLuan; 8 import luan.modules.BasicLuan;
7 9
8 10
9 public abstract class LuanState implements DeepCloneable<LuanState> { 11 public abstract class LuanState implements DeepCloneable {
10 12
11 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>(); 13 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>();
12 14
13 private LuanTable registry; 15 private Map registry;
14 16
15 protected LuanState() { 17 protected LuanState() {
16 registry = new LuanTable(); 18 registry = new HashMap();
17 } 19 }
18 20
19 protected LuanState(LuanState luan) {} 21 protected LuanState(LuanState luan) {}
20 22
21 @Override public void deepenClone(LuanState clone,DeepCloner cloner) { 23 @Override public void deepenClone(DeepCloneable clone,DeepCloner cloner) {
22 clone.registry = cloner.deepClone(registry); 24 ((LuanState)clone).registry = cloner.deepClone(registry);
23 } 25 }
24 26
25 public abstract LuanTable currentEnvironment(); 27 public abstract LuanTable currentEnvironment();
26 public abstract LuanSource currentSource(); 28 public abstract LuanSource currentSource();
27 29
28 public final LuanTable registry() { 30 public final Map registry() {
29 return registry; 31 return registry;
30 } 32 }
31 33
32 public static LuanState newInstance() { 34 public static LuanState newInstance() {
33 return LuanCompiler.newLuanState(); 35 return LuanCompiler.newLuanState();