Explorar o código

ncd: NCDVal: Add some functions on safe references.

Ambroz Bizjak %!s(int64=11) %!d(string=hai) anos
pai
achega
e0acf50aaf
Modificáronse 2 ficheiros con 22 adicións e 0 borrados
  1. 12 0
      ncd/NCDVal.c
  2. 10 0
      ncd/NCDVal.h

+ 12 - 0
ncd/NCDVal.c

@@ -886,6 +886,18 @@ NCDValRef NCDVal_Moved (NCDValMem *mem, NCDValRef val)
     return val2;
 }
 
+int NCDVal_IsSafeRefPlaceholder (NCDValSafeRef sval)
+{
+    return (sval.idx < -1);
+}
+
+int NCDVal_GetSafeRefPlaceholderId (NCDValSafeRef sval)
+{
+    ASSERT(NCDVal_IsSafeRefPlaceholder(sval))
+    
+    return (sval.idx - NCDVAL_MINIDX);
+}
+
 int NCDVal_HasOnlyContinuousStrings (NCDValRef val)
 {
     NCDVal__AssertVal(val);

+ 10 - 0
ncd/NCDVal.h

@@ -236,6 +236,16 @@ NCDValRef NCDVal_FromSafe (NCDValMem *mem, NCDValSafeRef sval);
  */
 NCDValRef NCDVal_Moved (NCDValMem *mem, NCDValRef val);
 
+/**
+ * Determines whether a safe reference is a placeholder.
+ */
+int NCDVal_IsSafeRefPlaceholder (NCDValSafeRef sval);
+
+/**
+ * Gets the placeholder ID of a placeholder safe reference.
+ */
+int NCDVal_GetSafeRefPlaceholderId (NCDValSafeRef sval);
+
 /**
  * Determines if all strings within this value are ContinuousString's,
  * by recusively walking the entire value.