mirror of https://github.com/rusefi/bldc.git
Squashed 'lispBM/lispBM/' changes from 7ed6fa3f..0c09634e
0c09634e added LEQ and GEQ comparisons 01fd1ec4 update change log git-subtree-dir: lispBM/lispBM git-subtree-split: 0c09634ea2ed217ecea0682feb314e0e45db1b64
This commit is contained in:
parent
629bd3702c
commit
4a8e60e198
|
@ -29,14 +29,20 @@
|
|||
/** LBM major version */
|
||||
#define LBM_MAJOR_VERSION 0
|
||||
/** LBM minor version */
|
||||
#define LBM_MINOR_VERSION 1
|
||||
#define LBM_MINOR_VERSION 2
|
||||
/** LBM patch revision */
|
||||
#define LBM_PATCH_VERSION 1
|
||||
#define LBM_PATCH_VERSION 0
|
||||
|
||||
|
||||
|
||||
/* Change log */
|
||||
|
||||
/* Feb 14 2022: version 0.2.0
|
||||
Added GEQ >= and LEQ <= comparisons.
|
||||
|
||||
/* Feb 13 2022: version 0.1.1
|
||||
Bug fix in handling of environments in progn. */
|
||||
|
||||
/* Feb 11 2022: First state to be given a numbered version (0.1.0) */
|
||||
|
||||
|
||||
|
|
|
@ -109,8 +109,10 @@
|
|||
#define SYM_NUMEQ 0x106
|
||||
#define SYM_LT 0x107
|
||||
#define SYM_GT 0x108
|
||||
#define SYM_EVAL 0x109
|
||||
#define SYM_EVAL_PROGRAM 0x10A
|
||||
#define SYM_LEQ 0x109
|
||||
#define SYM_GEQ 0x10A
|
||||
#define SYM_EVAL 0x10B
|
||||
#define SYM_EVAL_PROGRAM 0x10C
|
||||
|
||||
#define SYM_AND 0x110
|
||||
#define SYM_OR 0x111
|
||||
|
|
|
@ -893,6 +893,64 @@ lbm_value lbm_fundamental(lbm_value* args, lbm_uint nargs, lbm_value op) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SYM_LEQ: {
|
||||
lbm_uint a = args[0];
|
||||
lbm_uint b;
|
||||
bool r = true;
|
||||
bool ok = true;
|
||||
|
||||
if (!lbm_is_number(a)) {
|
||||
result = lbm_enc_sym(SYM_TERROR);
|
||||
break;
|
||||
}
|
||||
for (lbm_uint i = 1; i < nargs; i ++) {
|
||||
b = args[i];
|
||||
if (!lbm_is_number(b)) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
r = r && (compare(a, b) <= 0);
|
||||
}
|
||||
if (ok) {
|
||||
if (r) {
|
||||
result = lbm_enc_sym(SYM_TRUE);
|
||||
} else {
|
||||
result = lbm_enc_sym(SYM_NIL);
|
||||
}
|
||||
} else {
|
||||
result = lbm_enc_sym(SYM_TERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SYM_GEQ: {
|
||||
lbm_uint a = args[0];
|
||||
lbm_uint b;
|
||||
bool r = true;
|
||||
bool ok = true;
|
||||
|
||||
if (!lbm_is_number(a)) {
|
||||
result = lbm_enc_sym(SYM_TERROR);
|
||||
break;
|
||||
}
|
||||
for (lbm_uint i = 1; i < nargs; i ++) {
|
||||
b = args[i];
|
||||
if (!lbm_is_number(b)) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
r = r && (compare(a, b) >= 0);
|
||||
}
|
||||
if (ok) {
|
||||
if (r) {
|
||||
result = lbm_enc_sym(SYM_TRUE);
|
||||
} else {
|
||||
result = lbm_enc_sym(SYM_NIL);
|
||||
}
|
||||
} else {
|
||||
result = lbm_enc_sym(SYM_TERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SYM_NOT: {
|
||||
if (nargs == 0) {
|
||||
return lbm_enc_sym(SYM_NIL);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "symrepr.h"
|
||||
|
||||
#define NUM_SPECIAL_SYMBOLS 101
|
||||
#define NUM_SPECIAL_SYMBOLS 103
|
||||
#define NAME 0
|
||||
#define ID 1
|
||||
#define NEXT 2
|
||||
|
@ -110,6 +110,8 @@ special_sym const special_symbols[NUM_SPECIAL_SYMBOLS] = {
|
|||
{"=" , SYM_EQ},
|
||||
{"<" , SYM_LT},
|
||||
{">" , SYM_GT},
|
||||
{"<=" , SYM_LEQ},
|
||||
{">=" , SYM_GEQ},
|
||||
{"eval" , SYM_EVAL},
|
||||
{"eval-program" , SYM_EVAL_PROGRAM},
|
||||
{"and" , SYM_AND},
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
(and (= t (> 1 0))
|
||||
(= nil (< 1 0)))
|
|
@ -0,0 +1,2 @@
|
|||
(and (= t (>= 1 1))
|
||||
(= t (<= 1 1)))
|
|
@ -0,0 +1,2 @@
|
|||
(and (= t (>= 1 0))
|
||||
(= t (<= 0 1)))
|
|
@ -0,0 +1,2 @@
|
|||
(and (= nil (>= 0 1))
|
||||
(= nil (<= 1 0)))
|
Loading…
Reference in New Issue