tweak
[cdsspec-compiler.git] / benchmark / cliffc-hashtable / simplified_cliffc_hashtable.h
index 89efb8f393006ea6e40aa8bfd404eedda9f7f704..d30c4ab2685952f132547aed65868bc76ac6671a 100644 (file)
@@ -83,6 +83,9 @@ class cliffc_hashtable {
                # correctness. The key thing is to identify all the commit point.
        
                @Begin
+               @Options:
+                       LANG = C;
+                       CLASS = cliffc_hashtable;
                @Global_define:
                        @DeclareVar:
                        spec_hashtable<TypeK, TypeV*> map;
@@ -93,14 +96,15 @@ class cliffc_hashtable {
                                id_map = spec_hashtable<TypeK, TypeV*>();
                                tag = Tag();
                        @DefineFunc:
-                       static bool equals_val(TypeV *ptr1, TypeV *ptr2) {
+                       bool equals_val(TypeV *ptr1, TypeV *ptr2) {
                                // ...
                        }
                        
+                       @DefineFunc:
                        # Update the tag for the current key slot if the corresponding tag
                        # is NULL, otherwise just return that tag. It will update the next
                        # available tag too if it requires a new tag for that key slot.
-                       static Tag getKeyTag(TypeK &key) {
+                       Tag getKeyTag(TypeK &key) {
                                if (id_map.get(key) == NULL) {
                                        Tag cur_tag = tag.current();
                                        id_map.put(key, cur_tag);
@@ -366,7 +370,7 @@ friend class CHM;
                @Commit_point_set: Read_Val_Point1 | Read_Val_Point2 | Read_Val_Point3
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @DefineVar: TypeV *_Old_Val = __sequential.map.get(key)
+                       TypeV *_Old_Val = __sequential.map.get(key)
                @Post_check:
                        __sequential.equals_val(_Old_Val, __RET__)
                @End
@@ -388,8 +392,8 @@ friend class CHM;
                @ID: __sequential.getKeyTag(key)
                @Action:
                        # Remember this old value at checking point
-                       @DefineVar: TypeV *_Old_Val = __sequential.map.get(key)
-                       @Code: __sequential.map.put(key, &val);
+                       TypeV *_Old_Val = __sequential.map.get(key)
+                       __sequential.map.put(key, &val);
                @Post_check:
                        __sequential.equals_val(__RET__, _Old_Val)
                @End
@@ -408,12 +412,11 @@ friend class CHM;
                        COND_PutIfAbsentSucc :: __RET__ == NULL
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @DefineVar: TypeV *_Old_Val = __sequential.map.get(key)
-                       @Code:
-                       if (__COND_SAY__)
+                       TypeV *_Old_Val = __sequential.map.get(key)
+                       if (__COND_SAT__)
                                __sequential.map.put(key, &value);
                @Post_check:
-                       __COND_SAY__ ? __RET__ == NULL : __sequential.equals_val(_Old_Val, __RET__) 
+                       __COND_SAT__ ? __RET__ == NULL : __sequential.equals_val(_Old_Val, __RET__) 
                @End
        */
        shared_ptr<TypeV> putIfAbsent(TypeK& key, TypeV& value) {
@@ -426,8 +429,8 @@ friend class CHM;
                @Commit_point_set: Write_Val_Point
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @DefineVar: TypeV *_Old_Val = __sequential.map.get(key)
-                       @Code: __sequential.map.put(key, NULL);
+                       TypeV *_Old_Val = __sequential.map.get(key)
+                       __sequential.map.put(key, NULL);
                @Post_check:
                        __sequential.equals_val(__RET__, _Old_Val)
                @End
@@ -447,11 +450,10 @@ friend class CHM;
                        COND_RemoveIfMatchSucc :: __RET__ == true
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @Code:
-                       if (__COND_SAY__)
+                       if (__COND_SAT__)
                                __sequential.map.put(key, NULL);
                @Post_check:
-                       __COND_SAY__ ? __RET__ : !__RET__
+                       __COND_SAT__ ? __RET__ : !__RET__
                @End
        */
        bool remove(TypeK& key, TypeV& val) {
@@ -467,7 +469,7 @@ friend class CHM;
                        Write_Val_Point
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @DefineVar: TypeV *_Old_Val = __sequential.map.get(key)
+                       TypeV *_Old_Val = __sequential.map.get(key)
                @Post_check:
                        __sequential.equals_val(__RET__, _Old_Val)
                @End
@@ -487,11 +489,10 @@ friend class CHM;
                        COND_ReplaceIfMatchSucc :: __RET__ == true
                @ID: __sequential.getKeyTag(key)
                @Action:
-                       @Code:
-                       if (__COND_SAY__)
+                       if (__COND_SAT__)
                                __sequential.map.put(key, &newval);
                @Post_check:
-                       __COND_SAY__ ? __RET__ : !__RET__
+                       __COND_SAT__ ? __RET__ : !__RET__
                @End
        */
        bool replace(TypeK& key, TypeV& oldval, TypeV& newval) {