[Commit] nickle compile.c, 1.141, 1.142 hash.c, 1.2, 1.3 value.h,
1.91, 1.92
Keith Packard
commit at keithp.com
Fri Jul 25 17:47:57 PDT 2003
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv17353
Modified Files:
compile.c hash.c value.h
Log Message:
Hash tables map keys to storage. Compile array dims in the right order
Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- compile.c 24 Jul 2003 18:10:18 -0000 1.141
+++ compile.c 25 Jul 2003 23:47:54 -0000 1.142
@@ -3782,7 +3782,7 @@
CompileArrayDimValue (ObjPtr obj, TypePtr type, Bool lvalue, ExprPtr stat, CodePtr code)
{
ENTER ();
- InstPtr inst;
+ InstPtr inst = 0;
int d;
CodePtr c;
@@ -3816,6 +3816,22 @@
}
static ObjPtr
+CompileArrayDims (ObjPtr obj, ExprPtr dim, ExprPtr stat, CodePtr code)
+{
+ ENTER ();
+ if (dim)
+ {
+ InstPtr inst;
+ obj = CompileArrayDims (obj, dim->tree.right, stat, code);
+ obj = _CompileExpr (obj, dim->tree.left, True, stat, code);
+ BuildInst (obj, OpInitArray, inst, stat);
+ inst->ainit.dim = 0;
+ inst->ainit.mode = AInitModeElement;
+ }
+ RETURN (obj);
+}
+
+static ObjPtr
CompileArrayType (ObjPtr obj, ExprPtr decls, TypePtr type, ExprPtr stat, CodePtr code)
{
ENTER ();
@@ -3851,14 +3867,9 @@
BuildInst (*initObj, OpInitArray, inst, stat);
inst->ainit.mode = AInitModeStart;
inst->ainit.dim = 1;
- while (dim)
- {
- *initObj = _CompileExpr (*initObj, dim->tree.left, True, stat, code);
- BuildInst (*initObj, OpInitArray, inst, stat);
- inst->ainit.dim = 0;
- inst->ainit.mode = AInitModeElement;
- dim = dim->tree.right;
- }
+
+ *initObj = CompileArrayDims (*initObj, dim, stat, code);
+
BuildInst (*initObj, OpInitArray, inst, stat);
inst->ainit.dim = 1;
inst->ainit.mode = AInitModeElement;
Index: hash.c
===================================================================
RCS file: /local/src/CVS/nickle/hash.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hash.c 22 Jul 2003 04:32:35 -0000 1.2
+++ hash.c 25 Jul 2003 23:47:54 -0000 1.3
@@ -111,7 +111,7 @@
ht->count = 0;
for (h = old->nvalues / HashEltSize; h > 0; h--)
{
- if (HashEltCounted (o))
+ if (HashEltValid (o))
{
/* XXX must rewrite references */
n = Find (ht, HashEltHash(o), HashEltKey(o));
@@ -320,7 +320,7 @@
Resize (ht, ht->hashSet + 1);
}
he = Find (ht, hash, key);
- if (!HashEltCounted (he))
+ if (!HashEltValid (he))
ht->count++;
HashEltHash (he) = hash;
HashEltKey (he) = key;
@@ -341,7 +341,7 @@
Resize (ht, ht->hashSet + 1);
}
he = Find (ht, hash, key);
- if (!HashEltCounted (he))
+ if (!HashEltValid (he))
{
ht->count++;
HashEltHash (he) = hash;
@@ -370,18 +370,13 @@
Value hash = ValueHash (key);
he = Find (ht, hash, key);
- if (HashEltCounted (he))
+ if (HashEltValid (he))
{
/* mark this entry as deleted -- value Void, key NULL */
- HashEltValue (he) = Void;
- HashEltKey (he) = 0;
HashEltHash (he) = 0;
+ HashEltKey (he) = 0;
+ HashEltValue (he) = Void;
--ht->count;
- if (ht->count < ht->hashSet->entries / 4 &&
- ht->hashSet != &hashSets[0])
- {
- Resize (ht, ht->hashSet - 1);
- }
}
}
Index: value.h
===================================================================
RCS file: /local/src/CVS/nickle/value.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- value.h 24 Jul 2003 18:10:19 -0000 1.91
+++ value.h 25 Jul 2003 23:47:54 -0000 1.92
@@ -763,9 +763,8 @@
* v v valid entry
*
* So:
- * key != 0 -> count includes
+ * key != 0 -> hash table includes
* value != 0 -> hash chain includes
- * value != 0 && key != 0 -> hash table includes
*/
#define HashEltHash(e) ((e)[0])
@@ -776,9 +775,8 @@
#define HashEltCopy(d,s) (((d)[0] = (s)[0]), \
((d)[1] = (s)[1]), \
((d)[2] = (s)[2]))
-#define HashEltCounted(e) (HashEltKey(e) != 0)
+#define HashEltValid(e) (HashEltKey(e) != 0)
#define HashEltChained(e) (HashEltValue(e) != 0)
-#define HashEltValid(e) (HashEltKey(e) != 0 && HashEltValue(e) != 0)
typedef struct _hashTable {
BaseValue base;
More information about the Commit
mailing list