Skip to content

Commit 1ceddb5

Browse files
committed
Remove variable caches
1 parent 729f415 commit 1ceddb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+214
-212
lines changed

snap-compile/src/main/java/org/snapscript/compile/assemble/OperationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Object create(Type type, Object[] arguments, Line line) throws Exception
3232
Callable<Result> callable = binder.bind(scope, type, TYPE_CONSTRUCTOR, arguments);
3333

3434
if(callable == null) {
35-
throw new InternalStateException("No constructor for " + type + " at line " + line);
35+
throw new InternalStateException("No constructor for '" + type + "' at line " + line);
3636
}
3737
Result result = callable.call();
3838
Object value = result.getValue();

snap-compile/src/main/java/org/snapscript/compile/validate/ModuleValidator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ public void validate(Module module) throws Exception {
2121
String resource = module.getPath();
2222

2323
for(Type type : types) {
24-
Module parent = type.getModule();
25-
String prefix = parent.getName();
26-
String name = type.getName();
27-
2824
try {
2925
validator.validate(type);
3026
}catch(Exception e) {
31-
throw new InternalStateException("Invalid reference to '" + prefix + "." + name +"' in '" + resource + "'", e);
27+
throw new InternalStateException("Invalid reference to '" + type +"' in '" + resource + "'", e);
3228
}
3329
}
3430
}

snap-compile/src/main/java/org/snapscript/compile/validate/TypeValidator.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ private void validateHierarchy(Type type) throws Exception {
6666
}
6767
}
6868
if(matches == 0) {
69-
Module module = type.getModule();
70-
String resource = module.getName();
71-
String name = type.getName();
72-
73-
throw new InternalStateException("Type '" + resource + "." + name + "' not defined");
69+
throw new InternalStateException("Type '" + type + "' not defined");
7470
}
7571
}
7672
}
@@ -91,11 +87,7 @@ private void validateProperties(Type type) throws Exception {
9187
properties.validate(property);
9288
}
9389
if(matches == 0) {
94-
Module module = type.getModule();
95-
String resource = module.getName();
96-
String name = type.getName();
97-
98-
throw new InternalStateException("Type '" + resource + "." + name + "' have property '" + require + "'");
90+
throw new InternalStateException("Type '" + type + "' have property '" + require + "'");
9991
}
10092
}
10193
}

snap-compile/src/test/java/org/snapscript/compile/ClosureFunctionFinderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testFunctionFinder() throws Exception {
2727
Module module = new ContextModule(context, "/", "yy", 1);
2828
ClosureFunctionFinder finder = new ClosureFunctionFinder(loader);
2929
Signature signature = new Signature(Arrays.asList(new Parameter("n", loader.loadType(String.class))), module);
30-
Type type = new InvocationFunction(signature, null, null, null, "xx").getDefinition();
30+
Type type = new InvocationFunction(signature, null, null, null, "xx").getHandle();
3131
Function function = finder.find(type);
3232

3333
assertNotNull(function);

snap-compile/src/test/java/org/snapscript/compile/ClosureMatcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void testClosureMatcher() throws Exception {
3232
TypeLoader loader = context.getLoader();
3333
ClosureFunctionFinder finder = new ClosureFunctionFinder(loader);
3434
Signature signature = new Signature(Arrays.asList(new Parameter("n", loader.loadType(String.class))), module);
35-
Type type = new EmptyFunction(signature).getDefinition();
35+
Type type = new EmptyFunction(signature).getHandle();
3636
ConstraintConverter converter = matcher.match(type);
3737
Function function = new InvocationFunction(signature, null, type, null, "xx");
3838
Score score = converter.score(function);

snap-compile/src/test/java/org/snapscript/compile/define/MockType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import org.snapscript.core.Module;
77
import org.snapscript.core.Scope;
8+
import org.snapscript.core.TypeDescription;
89
import org.snapscript.core.TypeScope;
910
import org.snapscript.core.Type;
1011
import org.snapscript.core.annotation.Annotation;
@@ -13,6 +14,7 @@
1314

1415
public class MockType implements Type {
1516

17+
private final TypeDescription description;
1618
private final List<Annotation> annotations;
1719
private final List<Property> properties;
1820
private final List<Function> functions;
@@ -24,6 +26,7 @@ public class MockType implements Type {
2426
private final String name;
2527

2628
public MockType(Module module, String name, Type entry, Class type){
29+
this.description = new TypeDescription(this);
2730
this.annotations = new ArrayList<Annotation>();
2831
this.properties = new ArrayList<Property>();
2932
this.functions = new ArrayList<Function>();
@@ -87,6 +90,6 @@ public int getOrder(){
8790

8891
@Override
8992
public String toString() {
90-
return name;
93+
return description.toString();
9194
}
9295
}

snap-core/src/main/java/org/snapscript/core/CompoundScope.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public Scope getOuter() {
2222
return outer;
2323
}
2424

25+
@Override
26+
public Type getHandle() {
27+
return outer.getType();
28+
}
29+
2530
@Override
2631
public Type getType() {
2732
return outer.getType();
@@ -68,6 +73,11 @@ public Scope getInner() {
6873
public Scope getOuter() {
6974
return outer;
7075
}
76+
77+
@Override
78+
public Type getHandle() {
79+
return outer.getType();
80+
}
7181

7282
@Override
7383
public Type getType() {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.snapscript.core;
2+
3+
public interface Handle extends Any {
4+
Type getHandle();
5+
}

snap-core/src/main/java/org/snapscript/core/ModelScope.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public State getState() {
3232
return state;
3333
}
3434

35+
@Override
36+
public Type getHandle() {
37+
return null;
38+
}
39+
3540
@Override
3641
public Type getType() {
3742
return null;

snap-core/src/main/java/org/snapscript/core/ModuleScope.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public Model getModel() {
3030
return null;
3131
}
3232

33+
@Override
34+
public Type getHandle() {
35+
return null;
36+
}
37+
3338
@Override
3439
public Type getType() {
3540
return null;

0 commit comments

Comments
 (0)