Переглянути джерело

ncd: NCDInterpProcess: cosmetic changes

ambrop7 13 роки тому
батько
коміт
9576769d4e
2 змінених файлів з 23 додано та 11 видалено
  1. 13 10
      ncd/NCDInterpProcess.c
  2. 10 1
      ncd/NCDInterpProcess.h

+ 13 - 10
ncd/NCDInterpProcess.c

@@ -166,7 +166,7 @@ int NCDInterpProcess_Init (NCDInterpProcess *o, NCDProcess *process, NCDPlacehol
     }
     
     if (!NCDInterpProcess__Trie_Init(&o->trie)) {
-        BLog(BLOG_ERROR, "BStringTrie_Init failed");
+        BLog(BLOG_ERROR, "NCDInterpProcess__Trie_Init failed");
         goto fail1;
     }
     
@@ -321,6 +321,7 @@ int NCDInterpProcess_FindStatement (NCDInterpProcess *o, int from_index, const c
     
     while (stmt_idx >= 0) {
         struct NCDInterpProcess__stmt *e = &o->stmts[stmt_idx];
+        ASSERT(e->name)
         
         if (!strcmp(e->name, name) && stmt_idx < from_index) {
             return stmt_idx;
@@ -339,6 +340,7 @@ const char * NCDInterpProcess_StatementCmdName (NCDInterpProcess *o, int i)
     DebugObject_Access(&o->d_obj);
     ASSERT(i >= 0)
     ASSERT(i < o->num_stmts)
+    ASSERT(o->stmts[i].cmdname)
     
     return o->stmts[i].cmdname;
 }
@@ -410,15 +412,6 @@ void NCDInterpProcess_StatementBumpAllocSize (NCDInterpProcess *o, int i, int al
     }
 }
 
-int NCDInterpProcess_StatementPreallocSize (NCDInterpProcess *o, int i)
-{
-    DebugObject_Access(&o->d_obj);
-    ASSERT(i >= 0)
-    ASSERT(i < o->num_stmts)
-    
-    return o->stmts[i].alloc_size;
-}
-
 int NCDInterpProcess_PreallocSize (NCDInterpProcess *o)
 {
     DebugObject_Access(&o->d_obj);
@@ -431,6 +424,16 @@ int NCDInterpProcess_PreallocSize (NCDInterpProcess *o)
     return o->prealloc_size;
 }
 
+int NCDInterpProcess_StatementPreallocSize (NCDInterpProcess *o, int i)
+{
+    DebugObject_Access(&o->d_obj);
+    ASSERT(i >= 0)
+    ASSERT(i < o->num_stmts)
+    ASSERT(o->prealloc_size >= 0)
+    
+    return o->stmts[i].alloc_size;
+}
+
 int NCDInterpProcess_StatementPreallocOffset (NCDInterpProcess *o, int i)
 {
     DebugObject_Access(&o->d_obj);

+ 10 - 1
ncd/NCDInterpProcess.h

@@ -63,6 +63,15 @@ struct NCDInterpProcess__stmt {
     int trie_next;
 };
 
+/**
+ * A data structure which contains information about a process or
+ * template, suitable for efficient interpretation. These structures
+ * are built at startup from the program AST for all processes and
+ * templates by \link NCDInterpProg. They are not modified after
+ * the program is loaded Inn case of template processes, the same
+ * NCDInterpProcess is shared by all processes created from the same
+ * template.
+ */
 typedef struct {
     struct NCDInterpProcess__stmt *stmts;
     char *name;
@@ -82,8 +91,8 @@ const struct NCDModule * NCDInterpProcess_StatementGetSimpleModule (NCDInterpPro
 const struct NCDModule * NCDInterpProcess_StatementGetMethodModule (NCDInterpProcess *o, int i, const char *obj_type, NCDMethodIndex *method_index);
 int NCDInterpProcess_CopyStatementArgs (NCDInterpProcess *o, int i, NCDValMem *out_valmem, NCDValRef *out_val, NCDValReplaceProg *out_prog) WARN_UNUSED;
 void NCDInterpProcess_StatementBumpAllocSize (NCDInterpProcess *o, int i, int alloc_size);
-int NCDInterpProcess_StatementPreallocSize (NCDInterpProcess *o, int i);
 int NCDInterpProcess_PreallocSize (NCDInterpProcess *o);
+int NCDInterpProcess_StatementPreallocSize (NCDInterpProcess *o, int i);
 int NCDInterpProcess_StatementPreallocOffset (NCDInterpProcess *o, int i);
 const char * NCDInterpProcess_Name (NCDInterpProcess *o);
 int NCDInterpProcess_IsTemplate (NCDInterpProcess *o);