mirror of https://github.com/rusefi/bldc.git
Merge commit '444c98ea5203c070a942a71ebfae8946e683399d'
This commit is contained in:
commit
38506e3ea5
|
@ -1,78 +0,0 @@
|
|||
/** \page lbmdoc Introduction to LispBM programming
|
||||
\tableofcontents
|
||||
|
||||
\section sec_intro Introduction
|
||||
|
||||
WORK IN PROGRESS
|
||||
|
||||
LispBM is a lisp-like language implemented by a non-lisper. The inspiration for LispBM came from watching the <a
|
||||
href="https://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CABEA24090">
|
||||
SICP course on youtube </a> and a tiny amount of experimenting with EMACS
|
||||
lisp. I strongly recommend that you watch the SICP course, it is a lot of fun!<br>
|
||||
|
||||
LispBM does not try to implement any particular Lisp or Scheme standard but may
|
||||
be more scheme-like in nature.
|
||||
|
||||
|
||||
\section sec_repl Using a REPL
|
||||
|
||||
\code
|
||||
# :info
|
||||
--(LISP HEAP)-----------------------------------------------
|
||||
Heap size: 16384 Bytes
|
||||
Used cons cells: 11
|
||||
Free cons cells: 2037
|
||||
GC counter: 0
|
||||
Recovered: 0
|
||||
Recovered arrays: 0
|
||||
Marked: 0
|
||||
--(Symbol and Array memory)---------------------------------
|
||||
Memory size: 2048 Words
|
||||
Memory free: 2024 Words
|
||||
Allocated arrays: 0
|
||||
Symbol table size: 40 Bytes
|
||||
\endcode
|
||||
|
||||
|
||||
\code
|
||||
# :env
|
||||
Environment:
|
||||
\endcode
|
||||
|
||||
|
||||
\code
|
||||
# :ctxs
|
||||
****** Running contexts ******
|
||||
****** Blocked contexts ******
|
||||
****** Done contexts ******
|
||||
\endcode
|
||||
|
||||
|
||||
\code
|
||||
# :pause
|
||||
Evaluator paused
|
||||
\endcode
|
||||
|
||||
\code
|
||||
# :step
|
||||
\endcode
|
||||
|
||||
\code
|
||||
# :step 10
|
||||
\endcode
|
||||
|
||||
\code
|
||||
# :continue
|
||||
\endcode
|
||||
|
||||
|
||||
|
||||
|
||||
\section sec_program A first program
|
||||
|
||||
\section sec_c Integration into C code
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
https://github.com/svenssonjoel/lispBM
|
||||
|
||||
<h2> LispBM Language </h2>
|
||||
\ref lbmdoc <br>
|
||||
\ref lbmref <br>
|
||||
|
||||
<h2> Implementation documentation </h2>
|
||||
|
||||
C Interoperation: \ref lbm_c_interop.h <br>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
extern int lbm_init_env(void);
|
||||
/**
|
||||
* \deprecated There is no value in returning a pointer to the environment. Use lbm_get_env
|
||||
* Get a pointer to the global environment.
|
||||
* \return A pointer to the global environment variable.
|
||||
*/
|
||||
extern lbm_value *lbm_get_env_ptr(void);
|
||||
|
|
|
@ -47,6 +47,14 @@ extern int lbm_extensions_init(extension_fptr *extension_storage, int extension_
|
|||
* \return extension_fptr on success or NULL on failure.
|
||||
*/
|
||||
extern extension_fptr lbm_get_extension(lbm_uint sym);
|
||||
/** Reset an extension back to the default value.
|
||||
* Trying to apply the extension after clearing it will result
|
||||
* in an eval error.
|
||||
*
|
||||
* \param sym_id Symbol id of the extension to clear.
|
||||
* \return true if successfully cleared an extension otherwise false.
|
||||
*/
|
||||
extern bool lbm_clr_extension(lbm_uint sym_id);
|
||||
/** Adds a symbol-extension mapping.
|
||||
* \param sym_str String representation of symbol to use as key.
|
||||
* \param ext The extension function pointer.
|
||||
|
|
|
@ -25,9 +25,23 @@
|
|||
/** LBM minor version */
|
||||
#define LBM_MINOR_VERSION 5
|
||||
/** LBM patch revision */
|
||||
#define LBM_PATCH_VERSION 2
|
||||
#define LBM_PATCH_VERSION 3
|
||||
|
||||
/*! \page changelog Changelog
|
||||
May 10 2022: Version 0.5.3
|
||||
- symbols starting with "ext-" will be allocated into the extensions-list
|
||||
and can on the VESC version of lispbm be dynamically bound to newly loaded
|
||||
extensions at runtime.
|
||||
|
||||
May 8 2022: Version 0.5.2
|
||||
- Added new macros for 10, 12 and 14K lbm_memory sizes.
|
||||
|
||||
May 5 2022: Version 0.5.2
|
||||
- Line and column numbers associated with read errors.
|
||||
- More explanatory descriptions in error messages related to read errors.
|
||||
|
||||
May 2 2022: Version 0.5.2
|
||||
- Performance tweaks to the evaluator. Small but positive effect.
|
||||
|
||||
May 1 2022: Version 0.5.2
|
||||
- Added lbm_stack_reserve for allocating multiple words on stack
|
||||
|
|
|
@ -57,6 +57,15 @@ extension_fptr lbm_get_extension(lbm_uint sym) {
|
|||
return extension_table[ext_next];
|
||||
}
|
||||
|
||||
bool lbm_clr_extension(lbm_uint sym_id) {
|
||||
lbm_uint ext_id = sym_id - ext_offset;
|
||||
if (ext_id >= ext_max) {
|
||||
return false;
|
||||
}
|
||||
extension_table[ext_id] = lbm_extensions_default;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lbm_add_extension(char *sym_str, extension_fptr ext) {
|
||||
lbm_value symbol;
|
||||
lbm_uint ext_ix = 0;
|
||||
|
|
|
@ -599,15 +599,15 @@ lbm_value array_extension_buffer_get_u8(lbm_value *args, lbm_uint argn) {
|
|||
}
|
||||
|
||||
lbm_uint index = lbm_dec_as_u32(args[1]);
|
||||
lbm_uint value = 0;
|
||||
lbm_int value = 0;
|
||||
|
||||
if (index >= array->size) {
|
||||
return res;
|
||||
}
|
||||
uint8_t *data = (uint8_t*)array->data;
|
||||
|
||||
value = data[index];
|
||||
res = lbm_enc_u(value);
|
||||
value = (lbm_int)data[index];
|
||||
res = lbm_enc_i(value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ lbm_value array_extension_buffer_get_u16(lbm_value *args, lbm_uint argn) {
|
|||
}
|
||||
|
||||
lbm_uint index = lbm_dec_as_u32(args[1]);
|
||||
lbm_uint value = 0;
|
||||
lbm_int value = 0;
|
||||
|
||||
if (index+1 >= array->size) {
|
||||
return res;
|
||||
|
@ -644,16 +644,16 @@ lbm_value array_extension_buffer_get_u16(lbm_value *args, lbm_uint argn) {
|
|||
uint8_t *data = (uint8_t*)array->data;
|
||||
|
||||
if (be) {
|
||||
value =
|
||||
value = (lbm_int)(
|
||||
(lbm_uint) data[index+1] |
|
||||
(lbm_uint) data[index] << 8;
|
||||
(lbm_uint) data[index] << 8);
|
||||
} else {
|
||||
value =
|
||||
value = (lbm_int)(
|
||||
(lbm_uint) data[index] |
|
||||
(lbm_uint) data[index+1] << 8;
|
||||
(lbm_uint) data[index+1] << 8);
|
||||
}
|
||||
|
||||
res = lbm_enc_u(value);
|
||||
res = lbm_enc_i(value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
(define arr (array-create type-byte 19))
|
||||
|
||||
(bufset-u8 arr 0 255)
|
||||
(bufset-u8 arr 1 127)
|
||||
(bufset-u8 arr 18 1100)
|
||||
|
||||
(and (= (bufget-u8 arr 0) 255)
|
||||
(= (bufget-u8 arr 1) 127)
|
||||
(= (bufget-u8 arr 18) (mod 1100 256)))
|
|
@ -0,0 +1,9 @@
|
|||
(define arr (array-create type-byte 10))
|
||||
|
||||
(bufset-u16 arr 0 65535)
|
||||
(bufset-u16 arr 2 10)
|
||||
(bufset-u16 arr 4 11700)
|
||||
|
||||
(and (= (bufget-u16 arr 0) 65535)
|
||||
(= (bufget-u16 arr 2) 10)
|
||||
(= (bufget-u16 arr 4) (mod 11700 65536)))
|
Loading…
Reference in New Issue