[use the new atom implementation everywhere
John Meacham <john@repetae.net>**20080210091348] hunk ./E/Annotate.hs 142
-    | i <= 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+    | isEtherialId i || i == 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
hunk ./E/LambdaLift.hs 10
-import Atom
+import StringTable.Atom
hunk ./E/LambdaLift.hs 279
-        globalName tvr | isNothing $ intToAtom (tvrIdent tvr) = do
+        globalName tvr | not $ isValidAtom (tvrIdent tvr) = do
hunk ./E/Program.hs 68
-programSetDs ds prog | flint && any (isNothing . intToAtom) (map (tvrIdent . fst) ds) = error $ "programSetDs: trying to set non unique top level name: \n" ++ intercalate "\n"  (sort $ map (show . tvrShowName . fst) ds)
+programSetDs ds prog | flint && any (not . isValidAtom) (map (tvrIdent . fst) ds) = error $ "programSetDs: trying to set non unique top level name: \n" ++ intercalate "\n"  (sort $ map (show . tvrShowName . fst) ds)
hunk ./E/SSimplify.hs 22
-import Atom
+import StringTable.Atom
hunk ./E/SSimplify.hs 534
-    showName t | isJust (intToAtom t) || dump FD.EVerbose = tvrShowName (tVr t Unknown)
+    showName t | isValidAtom t || dump FD.EVerbose = tvrShowName (tVr t Unknown)
hunk ./E/Show.hs 132
-allocTVr tvr (SEM action) | isNothing $ intToAtom (tvrIdent tvr) = do
+allocTVr tvr (SEM action) | not $ isValidAtom (tvrIdent tvr) = do
hunk ./E/Subst.hs 152
-    | i <= 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+--    | i <= 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
+    | isEtherialId i || i == 0 || i `mmember` ss = nv (fromList [ (x,undefined) | x <- xs ] `mappend` ss)
hunk ./E/Traverse.hs 156
-        n' <- if n > 0 && (not ralways || isJust (intToAtom n)) then uniqueName  n else newName
+        --n' <- if n > 0 && (not ralways || isValidAtom n) then uniqueName  n else newName
+        n' <- if not (isEtherialId n) && (not ralways || isValidAtom n) then uniqueName  n else newName
+        --n' <- if (not ralways || isValidAtom n) then uniqueName  n else newName
hunk ./Info/Info.hs 79
+lookupTyp :: forall a . Typeable a => a -> Info -> Maybe a
+lookupTyp a = f where
+    f (Info mp) = g mp
+    typ = typeOf (undefined :: a)
+    g [] = fail "Info: could not find " ++ show typ
hunk ./Main.hs 96
+catom action = action `finally` dumpToFile
hunk ./Main.hs 249
+    wdump FD.CoreInitial $
+        mapM_ (\(v,lc) -> printCheckName'' fullDataTable v lc) ds
hunk ./Main.hs 904
-    let f (tvr@TVr { tvrIdent = n },e) | isNothing $ intToAtom n = do
+    let f (tvr@TVr { tvrIdent = n },e) | not $ isValidAtom n = do
hunk ./Makefile.am 51
-GHCOPTS=  $(HSOPTS)  -O -ignore-package lang  $(GHCDEBUGOPTS) $(GHCINC) $(PACKAGES) $(GHCLANG) -optc-std=c99
+GHCOPTS=  $(HSOPTS)  -O -ignore-package lang  $(GHCDEBUGOPTS) $(GHCINC) $(PACKAGES) $(GHCLANG) -optc-std=c99 -optc-O2 -optc-Wall
hunk ./Name/Id.hs 12
+    etherialIds,
+    isEtherialId,
hunk ./Name/Id.hs 159
+etherialIds :: [Id]
+etherialIds = [-1, -2 .. -100 ]
+isEtherialId id = id < 0 && id >= -100
+
hunk ./Name/Name.hs 28
-import Atom
+import StringTable.Atom
hunk ./Name/Name.hs 145
-nameType (Name a) = toEnum (ord (head (toString a)))
+nameType (Name a) = toEnum (ord (head (fromAtom a)))
hunk ./Name/Name.hs 148
-nameName (Name a) = f $ tail (toString a) where
+nameName (Name a) = f $ tail (fromAtom a) where
hunk ./Name/Name.hs 151
-    f _ = error $ "invalid Name: " ++ (show $ toString a)
+    f _ = error $ "invalid Name: " ++ (show $ (fromAtom a :: String))
hunk ./Name/Name.hs 154
-nameParts n@(Name a) = f $ tail (toString a) where
+nameParts n@(Name a) = f $ tail (fromAtom a) where
hunk ./Name/Name.hs 166
-toId x = atomIndex (toAtom x)
+toId x = fromAtom (toAtom x)
hunk ./Name/Name.hs 169
-fromId i | even i || i < 0 = fail $ "Name.fromId: not a name " ++ show i
+--fromId i | even i || i < 0 = fail $ "Name.fromId: not a name " ++ show i
+fromId i | not $ isValidAtom i = fail $ "Name.fromId: not a name " ++ show i
hunk ./StringTable/Atom.hsc 7
+    isValidAtom,
hunk ./StringTable/Atom.hsc 11
+    dumpToFile,
hunk ./StringTable/Atom.hsc 19
+import qualified Data.ByteString.Unsafe as BS
hunk ./StringTable/Atom.hsc 77
-    toAtomIO bs = BS.useAsCStringLen bs toAtomIO
+    toAtomIO bs = BS.unsafeUseAsCStringLen bs toAtomIO
hunk ./StringTable/Atom.hsc 90
-        (p,l) <- fromAtomIO a :: IO CStringLen
-        BS.packCStringLen (p,fromIntegral l)
-    --    fp <- newForeignPtr_ =<< (castPtr `fmap` peek p)
-    --    return $ BS.fromForeignPtr fp 0 (fromIntegral l)
+        sl <- fromAtomIO a :: IO CStringLen
+        BS.unsafePackCStringLen sl
hunk ./StringTable/Atom.hsc 104
-intToAtom i = if 0 /= (#const VALID_BITMASK) .&. i then return (Atom $ fromIntegral i) else fail $ "intToAtom: " ++ show i
+intToAtom i = if isValidAtom i then return (Atom $ fromIntegral i) else fail $ "intToAtom: " ++ show i
+
+isValidAtom :: Int -> Bool
+isValidAtom i = i < -100
hunk ./StringTable/Atom.hsc 114
-foreign import ccall unsafe "stringtable_get" stGet :: Atom -> Ptr CChar -> IO CInt
hunk ./StringTable/Atom.hsc 118
+foreign import ccall unsafe "dump_to_file" dumpToFile :: IO ()
hunk ./StringTable/StringTable_cbits.c 5
+#include <ctype.h>
hunk ./StringTable/StringTable_cbits.c 8
-//#define NDEBUG 1
+#define NDEBUG 1
hunk ./StringTable/StringTable_cbits.c 16
+#define pthread_mutex_lock(x) ;
+#define pthread_mutex_unlock(x) ;
+
hunk ./StringTable/StringTable_cbits.c 24
-static uint32_t hash3(uint32_t salt,unsigned char *key, int key_len);
+static void print_quoted(FILE *file,unsigned char *s,int len);
hunk ./StringTable/StringTable_cbits.c 39
-#define ATOM_PTR(c) (&(stringtable_chunks[CHUNK_INDEX(c)][CHUNK_OFFSET(c)]))
+#define ATOM_PTR(c) ((unsigned char *)&(stringtable_chunks[CHUNK_INDEX(c)][CHUNK_OFFSET(c)]))
hunk ./StringTable/StringTable_cbits.c 118
-bool
+static bool
hunk ./StringTable/StringTable_cbits.c 125
-bool
-item_exists(char *cs, int len) {
+static bool
+item_exists(unsigned char *cs, int len) {
hunk ./StringTable/StringTable_cbits.c 137
+void
+dump_to_file(void) {
+        FILE *file = fopen("atom.dump","w");
+        for(int i = 0; i < HASHSIZE*CUCKOO_HASHES; i++) {
+                atom_t a = htable[i].atom;
+                if(ATOM_VALID(a)) {
+                        fprintf(file,"%u:",ATOM_LEN(a));
+                        print_quoted(file, ATOM_PTR(a),ATOM_LEN(a));
+                        fwrite("\n",1,1,file);
+                }
+        }
+}
+
hunk ./StringTable/StringTable_cbits.c 165
-    fprintf(stderr,"grow_table[[[\n");
+ //   fprintf(stderr,"grow_table[[[\n");
hunk ./StringTable/StringTable_cbits.c 175
-    fprintf(stderr,"]]]\n");
+//    fprintf(stderr,"]]]\n");
hunk ./StringTable/StringTable_cbits.c 187
-         fprintf(stderr,"hash_insert(%x,%p:%i,%x,%x,[%x,%x]", x.atom, ATOM_PTR(x.atom), ATOM_LEN(x.atom), x.hashes[0], x.hashes[1],HASH_INDEX(0,x.hashes[0]),HASH_INDEX(1,x.hashes[1]));
+//         fprintf(stderr,"hash_insert(%x,%p:%i,%x,%x,[%x,%x]", x.atom, ATOM_PTR(x.atom), ATOM_LEN(x.atom), x.hashes[0], x.hashes[1],HASH_INDEX(0,x.hashes[0]),HASH_INDEX(1,x.hashes[1]));
hunk ./StringTable/StringTable_cbits.c 189
-        if(item_exists(ATOM_PTR(x.atom),ATOM_LEN(x.atom))) 
+        if(item_exists(ATOM_PTR(x.atom),ATOM_LEN(x.atom)))
hunk ./StringTable/StringTable_cbits.c 202
-                                        fprintf(stderr,")\n");
+//                                        fprintf(stderr,")\n");
hunk ./StringTable/StringTable_cbits.c 216
-        fprintf(stderr,"R");
+//        fprintf(stderr,"R");
hunk ./StringTable/StringTable_cbits.c 222
+static void
+print_quoted(FILE *file,unsigned char *s,int len)
+{
+        for(int i = 0;i < len; i ++) {
+                switch(s[i]) {
+                case '\n': fputs("\\n",file); continue;
+                case '\r': fputs("\\r",file); continue;
+                case '\t': fputs("\\t",file); continue;
+                default: ;
+                }
+                if(isprint(s[i]))
+                        fputc(s[i],file);
+                else
+                        fprintf(file,"\\x%2.2X", (unsigned)s[i]);
+        }
+}
+
+
hunk ./StringTable/StringTable_cbits.c 243
-        fprintf(stderr,"stringtable_lookup(%c,%c,%*s,%i)\n",cs[0],cs[1],len,cs,len);
+        static FILE *file = NULL;
+        if(!file)
+                file = fopen("atom.lookup","w");
+        fprintf(file,"stringtable_lookup(");
+        print_quoted(file,cs,len);
+        fprintf(file,")\n");