]> andersk Git - splint.git/blobdiff - src/constraintGeneration.c
Tried to fix some problems with the configuration system.
[splint.git] / src / constraintGeneration.c
index b94e2b4f4575a62116e04fbcc5ba414b506afe05..c681fb513a858ba1b104883d37ff8c4d39cc7add 100644 (file)
@@ -2184,3 +2184,69 @@ constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
   DPRINTF (( message("Returning list %q ", constraintList_printDetailed(preconditions) ) ));
   return preconditions;
 }
+
+/*drl added this function 10.29.001
+  takes an exprNode of the form const + const
+  and sets the value
+*/
+/*drl
+  I'm a bit nervous about modifying the exprNode
+  but this is the easy way to do this
+  If I have time I'd like to cause the exprNode to get created correctly in the first place */
+/*@i223*/
+void exprNode_findValue( exprNode e)
+{
+  exprData data;
+
+  exprNode t1, t2;
+  lltok tok;
+
+  data = e->edata;
+  
+  if (exprNode_hasValue(e) )
+    return;
+
+  if (e->kind == XPR_OP)
+    {
+      t1 = exprData_getOpA (data);
+     t2 = exprData_getOpB (data);
+     tok = exprData_getOpTok (data);
+
+     exprNode_findValue(t1);
+     exprNode_findValue(t2);
+
+     if (!(exprNode_knownIntValue(t1) && (exprNode_knownIntValue(t2) ) ) )
+       return;
+     
+     if (lltok_isPlus_Op (tok) )
+       {
+        long v1, v2;
+
+        v1 = exprNode_getLongValue(t1);
+        v2 = exprNode_getLongValue(t2);
+
+        if (multiVal_isDefined(e->val) )
+          multiVal_free (e->val);
+        
+        e->val = multiVal_makeInt (v1 + v2);
+       }
+
+     if ( lltok_isMinus_Op (tok) ) 
+       {
+        long v1, v2;
+
+        v1 = exprNode_getLongValue(t1);
+        v2 = exprNode_getLongValue(t2);
+
+        if (multiVal_isDefined(e->val) )
+          multiVal_free (e->val);
+        
+        e->val = multiVal_makeInt (v1 - v2);
+       }
+
+     /*drl I should really do * and / at some point */
+     
+    }
+
+}
+
This page took 0.05103 seconds and 4 git commands to generate.