Sfoglia il codice sorgente

ncd: NCDModule: implement NCDModuleInst_Backend_DownUp() and use it in the backtrack_point()

ambrop7 13 anni fa
parent
commit
9c149a1b1f
3 ha cambiato i file con 19 aggiunte e 2 eliminazioni
  1. 9 0
      ncd/NCDModule.c
  2. 9 0
      ncd/NCDModule.h
  3. 1 2
      ncd/modules/backtrack.c

+ 9 - 0
ncd/NCDModule.c

@@ -265,6 +265,15 @@ void NCDModuleInst_Backend_Down (NCDModuleInst *n)
     frontend_event(n, NCDMODULE_EVENT_DOWN);
 }
 
+void NCDModuleInst_Backend_DownUp (NCDModuleInst *n)
+{
+    DebugObject_Access(&n->d_obj);
+    ASSERT(n->state == STATE_UP)
+    
+    frontend_event(n, NCDMODULE_EVENT_DOWN);
+    frontend_event(n, NCDMODULE_EVENT_UP);
+}
+
 void NCDModuleInst_Backend_Dead (NCDModuleInst *n)
 {
     DebugObject_Access(&n->d_obj);

+ 9 - 0
ncd/NCDModule.h

@@ -496,6 +496,15 @@ void NCDModuleInst_Backend_Up (NCDModuleInst *n);
  */
 void NCDModuleInst_Backend_Down (NCDModuleInst *n);
 
+/**
+ * Puts the backend instance into down state, then immediatly back into the up state.
+ * This effectively causes the interpreter to start backtracking to this statement.
+ * The instance must be in up state, and remains in up state.
+ * 
+ * @param n backend instance handle
+ */
+void NCDModuleInst_Backend_DownUp (NCDModuleInst *n);
+
 /**
  * Destroys the backend instance.
  * The backend instance handle becomes invalid and must not be used from

+ 1 - 2
ncd/modules/backtrack.c

@@ -80,8 +80,7 @@ static void go_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleI
     NCDModuleInst_Backend_Up(i);
     
     // toggle backtrack point
-    NCDModuleInst_Backend_Down(backtrack_point_inst);
-    NCDModuleInst_Backend_Up(backtrack_point_inst);
+    NCDModuleInst_Backend_DownUp(backtrack_point_inst);
     return;
     
 fail0: