670
|
1 package luan.impl;
|
|
2
|
1578
|
3 import luan.LuanMutable;
|
1561
|
4 import luan.LuanException;
|
670
|
5
|
|
6
|
1578
|
7 public final class Pointer implements LuanMutable {
|
1561
|
8 private Object o;
|
|
9 private boolean immutable = false;
|
670
|
10
|
671
|
11 public Pointer() {}
|
|
12
|
|
13 public Pointer(Object o) {
|
|
14 this.o = o;
|
|
15 }
|
|
16
|
1578
|
17 @Override public boolean isImmutable() {
|
|
18 return immutable;
|
670
|
19 }
|
|
20
|
1578
|
21 @Override public void makeImmutable() {
|
|
22 if(immutable)
|
|
23 return;
|
1561
|
24 immutable = true;
|
1578
|
25 LuanMutable.makeImmutable(o);
|
1561
|
26 }
|
|
27
|
|
28 public Object get() {
|
|
29 return o;
|
|
30 }
|
|
31
|
|
32 public void set(Object o) throws LuanException {
|
|
33 if( immutable )
|
|
34 throw new LuanException("variable is immutable");
|
|
35 this.o = o;
|
|
36 }
|
670
|
37 }
|