diff options
author | schinz <schinz@epfl.ch> | 2005-03-10 08:34:08 +0000 |
---|---|---|
committer | schinz <schinz@epfl.ch> | 2005-03-10 08:34:08 +0000 |
commit | 7501dbe6ea156f6f6ddd253a6befa2f4d6920440 (patch) | |
tree | 72c44b7b3f738e6c224e23e87953215e2501fb8a | |
parent | 98447d6dd236eb26e63e374b1a1af64b60bb4e67 (diff) | |
download | scala-7501dbe6ea156f6f6ddd253a6befa2f4d6920440.tar.gz scala-7501dbe6ea156f6f6ddd253a6befa2f4d6920440.tar.bz2 scala-7501dbe6ea156f6f6ddd253a6befa2f4d6920440.zip |
- added support for statistics
-rw-r--r-- | sources/scala/runtime/types/ClassType.java | 3 | ||||
-rw-r--r-- | sources/scala/runtime/types/CompoundType.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/JavaRefArrayType.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/ScalaClassType.java | 5 | ||||
-rw-r--r-- | sources/scala/runtime/types/SingleType.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeAll.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeAllRef.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeAny.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeBoolean.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeByte.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeChar.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeConstructor.java | 5 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeDouble.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeFloat.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeInt.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeLong.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeShort.java | 1 | ||||
-rw-r--r-- | sources/scala/runtime/types/TypeUnit.java | 1 |
18 files changed, 25 insertions, 3 deletions
diff --git a/sources/scala/runtime/types/ClassType.java b/sources/scala/runtime/types/ClassType.java index 24518ab6bf..6a0e682852 100644 --- a/sources/scala/runtime/types/ClassType.java +++ b/sources/scala/runtime/types/ClassType.java @@ -14,7 +14,7 @@ import scala.Type; import scala.Array; import scala.runtime.RunTime; -public class ClassType extends Type { +public abstract class ClassType extends Type { public final Class clazz; public final boolean isTrivial; @@ -35,6 +35,7 @@ public class ClassType extends Type { } public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); return clazz.isInstance(o); } diff --git a/sources/scala/runtime/types/CompoundType.java b/sources/scala/runtime/types/CompoundType.java index bd53ea2aae..662d46cfa5 100644 --- a/sources/scala/runtime/types/CompoundType.java +++ b/sources/scala/runtime/types/CompoundType.java @@ -42,6 +42,7 @@ public class CompoundType extends Type { } public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); for (int i = 0; i < components.length; ++i) { if (!components[i].isInstance(o)) return false; diff --git a/sources/scala/runtime/types/JavaRefArrayType.java b/sources/scala/runtime/types/JavaRefArrayType.java index 466d537626..1c5e65a1b6 100644 --- a/sources/scala/runtime/types/JavaRefArrayType.java +++ b/sources/scala/runtime/types/JavaRefArrayType.java @@ -36,6 +36,7 @@ public class JavaRefArrayType extends Type { } public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); // TODO plus fin: on doit tenir compte de la version effacée // de elemType. return (o instanceof Object[]); diff --git a/sources/scala/runtime/types/ScalaClassType.java b/sources/scala/runtime/types/ScalaClassType.java index ae24baa529..220be35463 100644 --- a/sources/scala/runtime/types/ScalaClassType.java +++ b/sources/scala/runtime/types/ScalaClassType.java @@ -130,9 +130,12 @@ public class ScalaClassType extends ClassType { ScalaClassType[] thisSlice = getDisplay()[that.constr.level]; for (int i = 0; i < thisSlice.length; ++i) { - if (thisSlice[i].constr == that.constr) + if (thisSlice[i].constr == that.constr) { + assert Statistics.addDisplaySearchIterations(i + 1); return thisSlice[i]; + } } + assert Statistics.addDisplaySearchIterations(thisSlice.length); return null; } diff --git a/sources/scala/runtime/types/SingleType.java b/sources/scala/runtime/types/SingleType.java index 94f85371ba..ea1c10c2ae 100644 --- a/sources/scala/runtime/types/SingleType.java +++ b/sources/scala/runtime/types/SingleType.java @@ -29,6 +29,7 @@ public class SingleType extends Type { } public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); return o == instance; } diff --git a/sources/scala/runtime/types/TypeAll.java b/sources/scala/runtime/types/TypeAll.java index 10796e730d..07054bbc8b 100644 --- a/sources/scala/runtime/types/TypeAll.java +++ b/sources/scala/runtime/types/TypeAll.java @@ -16,6 +16,7 @@ import scala.Array; public class TypeAll extends SpecialType { public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); return false; } diff --git a/sources/scala/runtime/types/TypeAllRef.java b/sources/scala/runtime/types/TypeAllRef.java index 92848c1911..d2bb862f54 100644 --- a/sources/scala/runtime/types/TypeAllRef.java +++ b/sources/scala/runtime/types/TypeAllRef.java @@ -16,6 +16,7 @@ import scala.Array; public class TypeAllRef extends SpecialType { public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); return false; } diff --git a/sources/scala/runtime/types/TypeAny.java b/sources/scala/runtime/types/TypeAny.java index 7aa8417c18..07d36ba2b8 100644 --- a/sources/scala/runtime/types/TypeAny.java +++ b/sources/scala/runtime/types/TypeAny.java @@ -16,6 +16,7 @@ import scala.Array; public class TypeAny extends SpecialType { public boolean isInstance(Object o) { + assert Statistics.incInstanceOf(); return true; } diff --git a/sources/scala/runtime/types/TypeBoolean.java b/sources/scala/runtime/types/TypeBoolean.java index 3d938040ad..9df80d14dc 100644 --- a/sources/scala/runtime/types/TypeBoolean.java +++ b/sources/scala/runtime/types/TypeBoolean.java @@ -21,6 +21,7 @@ public class TypeBoolean extends ValueType { return RunTime.box_zarray(new boolean[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Boolean)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeByte.java b/sources/scala/runtime/types/TypeByte.java index a3941d771d..542b5b7bd9 100644 --- a/sources/scala/runtime/types/TypeByte.java +++ b/sources/scala/runtime/types/TypeByte.java @@ -21,6 +21,7 @@ public class TypeByte extends ValueType { return RunTime.box_barray(new byte[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Byte)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeChar.java b/sources/scala/runtime/types/TypeChar.java index c4436aeedc..c9c0a86265 100644 --- a/sources/scala/runtime/types/TypeChar.java +++ b/sources/scala/runtime/types/TypeChar.java @@ -21,6 +21,7 @@ public class TypeChar extends ValueType { return RunTime.box_carray(new char[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Char)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeConstructor.java b/sources/scala/runtime/types/TypeConstructor.java index ba157ab9dc..5c34f130a7 100644 --- a/sources/scala/runtime/types/TypeConstructor.java +++ b/sources/scala/runtime/types/TypeConstructor.java @@ -105,7 +105,10 @@ public class TypeConstructor implements java.io.Serializable { } public ScalaClassType getInstantiation(Type[] args) { - return instMapModule.get((InstantiationMap.T)instances.get(), args); + ScalaClassType inst = + instMapModule.get((InstantiationMap.T)instances.get(), args); + assert Statistics.incInstantiations(inst == null); + return inst; } public ScalaClassType instantiate(Type[] args, ScalaClassType[] parents) { diff --git a/sources/scala/runtime/types/TypeDouble.java b/sources/scala/runtime/types/TypeDouble.java index 67ba67994a..541fdc4cdb 100644 --- a/sources/scala/runtime/types/TypeDouble.java +++ b/sources/scala/runtime/types/TypeDouble.java @@ -20,6 +20,7 @@ public public class TypeDouble extends ValueType { return RunTime.box_darray(new double[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Double)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeFloat.java b/sources/scala/runtime/types/TypeFloat.java index 570cc2df43..281d8b0fae 100644 --- a/sources/scala/runtime/types/TypeFloat.java +++ b/sources/scala/runtime/types/TypeFloat.java @@ -20,6 +20,7 @@ public class TypeFloat extends ValueType { return RunTime.box_farray(new float[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Float)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeInt.java b/sources/scala/runtime/types/TypeInt.java index 84f042eab3..6959968b17 100644 --- a/sources/scala/runtime/types/TypeInt.java +++ b/sources/scala/runtime/types/TypeInt.java @@ -21,6 +21,7 @@ public class TypeInt extends ValueType { return RunTime.box_iarray(new int[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Int)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeLong.java b/sources/scala/runtime/types/TypeLong.java index 33ec7bb6ff..98b621f09a 100644 --- a/sources/scala/runtime/types/TypeLong.java +++ b/sources/scala/runtime/types/TypeLong.java @@ -20,6 +20,7 @@ public class TypeLong extends ValueType { return RunTime.box_larray(new long[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Long)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeShort.java b/sources/scala/runtime/types/TypeShort.java index a28c24b0eb..c2fb81362c 100644 --- a/sources/scala/runtime/types/TypeShort.java +++ b/sources/scala/runtime/types/TypeShort.java @@ -20,6 +20,7 @@ public class TypeShort extends ValueType { return RunTime.box_sarray(new short[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Short)) throw new ClassCastException(); // TODO error message return o; diff --git a/sources/scala/runtime/types/TypeUnit.java b/sources/scala/runtime/types/TypeUnit.java index 430de84c59..87fc5d9a22 100644 --- a/sources/scala/runtime/types/TypeUnit.java +++ b/sources/scala/runtime/types/TypeUnit.java @@ -21,6 +21,7 @@ public class TypeUnit extends ValueType { return RunTime.box_oarray(new Object[size]); } public Object checkCastability(Object o) { + assert scala.runtime.types.Statistics.incTypeCast(); if (! (o == null || o instanceof scala.Unit)) throw new ClassCastException(); // TODO error message return o; |