more bug fix
[cdsspec-compiler.git] / grammer / spec.txt
index ed30de8b3e76bc78c9c1fbd46525d7ae0bfaed19..1ac8dc15792098ff6de3938343b3d5320ea8a73b 100644 (file)
@@ -1 +1,55 @@
-void enqueue(queue_t *q, unsigned int val)
+/**
+@Begin
+               @Options:
+                       LANG = C;
+                       CLASS = cliffc_hashtable;
+               @Global_define:
+                       @DeclareVar:
+                       spec_hashtable<TypeK, TypeV*> map;
+                       spec_hashtable<TypeK, Tag> id_map;
+                       Tag tag;
+                       @InitVar:
+                               map = spec_hashtable<TypeK, TypeV*>();
+                               id_map = spec_hashtable<TypeK, TypeV*>();
+                               tag = Tag();
+                       @DefineFunc:
+                       static bool equals_val(TypeV *ptr1, TypeV *ptr2) {
+                               // ...
+                       }
+                       
+                       # 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) {
+                               if (id_map.get(key) == NULL) {
+                                       Tag cur_tag = tag.current();
+                                       id_map.put(key, cur_tag);
+                                       tag.next();
+                                       return cur_tag;
+                               } else {
+                                       return id_map.get(key);
+                               }
+                       }
+               
+               @Interface_cluster:
+                       Read_interface = {
+                               Get,
+                               PutIfAbsent,
+                               RemoveAny,
+                               RemoveIfMatch,
+                               ReplaceAny,
+                               ReplaceIfMatch
+                       }
+                       
+                       Write_interface = {
+                               Put,
+                               PutIfAbsent(COND_PutIfAbsentSucc),
+                               RemoveAny,
+                               RemoveIfMatch(COND_RemoveIfMatchSucc),
+                               ReplaceAny,
+                               ReplaceIfMatch(COND_ReplaceIfMatchSucc)
+                       }
+               @Happens_before:
+                       Write_interface -> Read_interface
+               @End
+       */