Index: /trunk/src/kmk/expreval.c
===================================================================
--- /trunk/src/kmk/expreval.c	(revision 1728)
+++ /trunk/src/kmk/expreval.c	(revision 1729)
@@ -866,7 +866,6 @@
 static EXPRRET expr_op_defined(PEXPR pThis)
 {
-    PEXPRVAR          pVar = &pThis->aVars[pThis->iVar];
+    PEXPRVAR            pVar = &pThis->aVars[pThis->iVar];
     struct variable    *pMakeVar;
-    assert(pThis->iVar >= 0);
 
     expr_var_make_simple_string(pVar);
@@ -886,7 +885,6 @@
 static EXPRRET expr_op_target(PEXPR pThis)
 {
-    PEXPRVAR          pVar = &pThis->aVars[pThis->iVar];
+    PEXPRVAR            pVar = &pThis->aVars[pThis->iVar];
     struct file        *pFile = NULL;
-    assert(pThis->iVar >= 0);
 
     /*
@@ -929,4 +927,54 @@
 
 /**
+ * Convert to boolean.
+ *
+ * @returns Status code.
+ * @param   pThis       The instance.
+ */
+static EXPRRET expr_op_bool(PEXPR pThis)
+{
+    expr_var_make_bool(&pThis->aVars[pThis->iVar]);
+    return kExprRet_Ok;
+}
+
+
+/**
+ * Convert to number, works on quoted strings too.
+ *
+ * @returns Status code.
+ * @param   pThis       The instance.
+ */
+static EXPRRET expr_op_num(PEXPR pThis)
+{
+    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
+
+    /* unquote the string */
+    if (pVar->enmType == kExprVar_QuotedSimpleString)
+        pVar->enmType = kExprVar_SimpleString;
+    else if (pVar->enmType == kExprVar_QuotedString)
+        pVar->enmType = kExprVar_String;
+
+    return expr_var_make_num(pThis, pVar);
+}
+
+
+/**
+ * Convert to string (simplified and quoted)
+ *
+ * @returns Status code.
+ * @param   pThis       The instance.
+ */
+static EXPRRET expr_op_str(PEXPR pThis)
+{
+    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
+
+    expr_var_make_simple_string(pVar);
+    pVar->enmType = kExprVar_QuotedSimpleString;
+
+    return kExprRet_Ok;
+}
+
+
+/**
  * Pluss (dummy / make_integer)
  *
@@ -936,10 +984,6 @@
 static EXPRRET expr_op_pluss(PEXPR pThis)
 {
-    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 0);
-
-    return expr_var_make_num(pThis, pVar);
-}
-
+    return expr_var_make_num(pThis, &pThis->aVars[pThis->iVar]);
+}
 
 
@@ -952,7 +996,6 @@
 static EXPRRET expr_op_minus(PEXPR pThis)
 {
-    EXPRRET  rc;
-    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 0);
+    EXPRRET     rc;
+    PEXPRVAR    pVar = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar);
@@ -973,7 +1016,6 @@
 static EXPRRET expr_op_bitwise_not(PEXPR pThis)
 {
-    EXPRRET  rc;
-    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 0);
+    EXPRRET     rc;
+    PEXPRVAR    pVar = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar);
@@ -993,8 +1035,8 @@
 static EXPRRET expr_op_logical_not(PEXPR pThis)
 {
-    PEXPRVAR pVar = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 0);
-
-    expr_var_assign_bool(pVar, !expr_var_make_bool(pVar));
+    PEXPRVAR    pVar = &pThis->aVars[pThis->iVar];
+
+    expr_var_make_bool(pVar);
+    pVar->uVal.i = !pVar->uVal.i;
 
     return kExprRet_Ok;
@@ -1010,8 +1052,7 @@
 static EXPRRET expr_op_multiply(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1037,8 +1078,7 @@
 static EXPRRET expr_op_divide(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1064,8 +1104,7 @@
 static EXPRRET expr_op_modulus(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1091,8 +1130,7 @@
 static EXPRRET expr_op_add(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1117,8 +1155,7 @@
 static EXPRRET expr_op_sub(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1142,8 +1179,7 @@
 static EXPRRET expr_op_shift_left(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1168,8 +1204,7 @@
 static EXPRRET expr_op_shift_right(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1194,8 +1229,7 @@
 static EXPRRET expr_op_less_or_equal_than(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_unify_types(pThis, pVar1, pVar2, "<=");
@@ -1221,8 +1255,7 @@
 static EXPRRET expr_op_less_than(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_unify_types(pThis, pVar1, pVar2, "<");
@@ -1248,8 +1281,7 @@
 static EXPRRET expr_op_greater_or_equal_than(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_unify_types(pThis, pVar1, pVar2, ">=");
@@ -1275,8 +1307,7 @@
 static EXPRRET expr_op_greater_than(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     rc = expr_var_unify_types(pThis, pVar1, pVar2, ">");
@@ -1302,8 +1333,7 @@
 static EXPRRET expr_op_equal(PEXPR pThis)
 {
-    EXPRRET   rc = kExprRet_Ok;
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    EXPRRET     rc = kExprRet_Ok;
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     /*
@@ -1377,8 +1407,7 @@
 static EXPRRET expr_op_bitwise_and(PEXPR pThis)
 {
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    EXPRRET   rc;
-    assert(pThis->iVar >= 1);
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
+    EXPRRET     rc;
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1403,8 +1432,7 @@
 static EXPRRET expr_op_bitwise_xor(PEXPR pThis)
 {
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    EXPRRET   rc;
-    assert(pThis->iVar >= 1);
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
+    EXPRRET     rc;
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1429,8 +1457,7 @@
 static EXPRRET expr_op_bitwise_or(PEXPR pThis)
 {
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    EXPRRET   rc;
-    assert(pThis->iVar >= 1);
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
+    EXPRRET     rc;
 
     rc = expr_var_make_num(pThis, pVar1);
@@ -1455,7 +1482,6 @@
 static EXPRRET expr_op_logical_and(PEXPR pThis)
 {
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     if (   expr_var_make_bool(pVar1)
@@ -1478,7 +1504,6 @@
 static EXPRRET expr_op_logical_or(PEXPR pThis)
 {
-    PEXPRVAR  pVar1 = &pThis->aVars[pThis->iVar - 1];
-    PEXPRVAR  pVar2 = &pThis->aVars[pThis->iVar];
-    assert(pThis->iVar >= 1);
+    PEXPRVAR    pVar1 = &pThis->aVars[pThis->iVar - 1];
+    PEXPRVAR    pVar2 = &pThis->aVars[pThis->iVar];
 
     if (   expr_var_make_bool(pVar1)
@@ -1533,4 +1558,5 @@
 static EXPRRET expr_op_right_parenthesis(PEXPR pThis)
 {
+    assert(0);
     (void)pThis;
     return kExprRet_Ok;
@@ -1554,4 +1580,7 @@
     EXPR_OP("defined",     90,      1,    expr_op_defined),
     EXPR_OP("target",      90,      1,    expr_op_target),
+    EXPR_OP("bool",        90,      1,    expr_op_bool),
+    EXPR_OP("num",         90,      1,    expr_op_num),
+    EXPR_OP("str",         90,      1,    expr_op_str),
     EXPR_OP("+",           80,      1,    expr_op_pluss),
     EXPR_OP("-",           80,      1,    expr_op_minus),
@@ -1954,4 +1983,5 @@
         {
             pOp = pThis->apOps[pThis->iOp--];
+            assert(pThis->iVar + 1 >= pOp->cArgs);
             rc = pOp->pfn(pThis);
             if (rc < kExprRet_Error)
Index: /trunk/src/kmk/testcase-ifcond.kmk
===================================================================
--- /trunk/src/kmk/testcase-ifcond.kmk	(revision 1728)
+++ /trunk/src/kmk/testcase-ifcond.kmk	(revision 1729)
@@ -721,9 +721,47 @@
 # bool
 #
-
-
-#
-# string
-#
+$(warning unary operator: bool )
+if bool("Asdf") != 1
+$(error )
+endif
+if bool("") != 0
+$(error )
+endif
+
+
+#
+# bool
+#
+$(warning unary operator: num )
+if num("1234") != 1235 - 1
+$(error )
+endif
+if num('1234') != 1233 + 1
+$(error )
+endif
+
+
+#
+# str
+#
+$(warning unary operator: str )
+if str(a < b) != 1
+$(error )
+endif
+if str(a < b) != '1'
+$(error )
+endif
+if str( 1 ) != "1"
+$(error )
+endif
+if str( 1 ) != "1"
+$(error )
+endif
+if str( num(0x1000) ) != "4096"
+$(error )
+endif
+if str(0x1000) != 0x1000
+$(error )
+endif
 
 
