*polished.

This commit is contained in:
Wang Renxin 2017-06-15 13:28:55 +08:00
parent e73db1ce56
commit e25bb710c2
7 changed files with 26 additions and 24 deletions

Binary file not shown.

View File

@ -13,6 +13,7 @@ del /f /s /q *.obj
del /f /s /q *.pdb
del /f /s /q *.sdf
del /f /s /q *.suo
del /f /s /q *.user
del /f /s /q *.vc.db
del /f /s /q output\*.dep

View File

@ -3253,7 +3253,7 @@ static int mb_uu_getbom(const char** ch) {
}
#ifdef MB_ENABLE_UNICODE
/* Determine whether a buffer is a UTF8 encoded character, and return taken bytes */
/* Determine whether a buffer starts with a UTF8 encoded character, and return taken byte count */
static int mb_uu_ischar(const char* ch) {
/* Copyright 2008, 2009 Bjoern Hoehrmann, http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ */
# define _TAKE(__ch, __c, __r) do { __c = *__ch++; __r++; } while(0)
@ -4827,7 +4827,7 @@ static bool_t _is_operator_char(char c) {
);
}
/* Determine whether a character is a exponential char */
/* Determine whether a character is exponential char */
static bool_t _is_exponential_char(char c) {
return (c == 'e') || (c == 'E');
}
@ -7383,9 +7383,9 @@ static _ls_node_t* _node_at_list(_list_t* coll, int index) {
_fill_ranged(coll);
if(index >= 0 && index < (int)coll->count) {
/* Layout: HEAD ... LEFT ... PIVOT ... RIGHT ... TAIL
/* Position: HEAD ... LEFT ... PIVOT ... RIGHT ... TAIL
PIVOT is a cached node and,
LEN(HEAD to LEFT) == LEN(LEFT to PIVOT) && LEN(PIVOT to RIGHT) == LEN(RIGHT to TAIL)
PIVOT is a cached node
*/
int head = 0,
left = coll->cached_index / 2,
@ -12261,7 +12261,7 @@ int mb_get_class_userdata(struct mb_interpreter_t* s, void** l, void** d) {
#ifdef MB_ENABLE_CLASS
int result = MB_FUNC_OK;
if(!s || !l || !d) {
if(!s || !d) {
result = MB_FUNC_ERR;
goto _exit;
@ -12295,7 +12295,7 @@ int mb_set_class_userdata(struct mb_interpreter_t* s, void** l, void* d) {
#ifdef MB_ENABLE_CLASS
int result = MB_FUNC_OK;
if(!s || !l || !d) {
if(!s || !d) {
result = MB_FUNC_ERR;
goto _exit;
@ -12323,8 +12323,9 @@ int mb_get_value_by_name(struct mb_interpreter_t* s, void** l, const char* n, mb
int result = MB_FUNC_OK;
_ls_node_t* tmp = 0;
_object_t* obj = 0;
mb_unrefvar(l);
if(!s || !l || !n) {
if(!s || !n) {
result = MB_FUNC_ERR;
goto _exit;
@ -12350,7 +12351,7 @@ int mb_add_var(struct mb_interpreter_t* s, void** l, const char* n, mb_value_t v
_var_t* var = 0;
_ls_node_t* tmp = 0;
if(!s || !l || !n) {
if(!s || !n) {
result = MB_FUNC_ERR;
goto _exit;

View File

@ -352,7 +352,7 @@ extern "C" {
# define MB_LOOP_BREAK 101
# define MB_LOOP_CONTINUE 102
# define MB_SUB_RETURN 103
# define MB_EXTENDED_ABORT 1001
# define MB_EXTENDED_ABORT 201
#endif /* MB_CODES */
#ifndef mb_check
@ -570,7 +570,7 @@ typedef int (* mb_has_routine_arg_func_t)(struct mb_interpreter_t*, void**, mb_v
typedef int (* mb_pop_routine_arg_func_t)(struct mb_interpreter_t*, void**, mb_value_t*, unsigned, unsigned*, void*, mb_value_t*);
typedef int (* mb_routine_func_t)(struct mb_interpreter_t*, void**, mb_value_t*, unsigned, void*, mb_has_routine_arg_func_t, mb_pop_routine_arg_func_t);
typedef int (* mb_debug_stepped_handler_t)(struct mb_interpreter_t*, void**, char*, int, unsigned short, unsigned short);
typedef void (* mb_error_handler_t)(struct mb_interpreter_t*, enum mb_error_e, char*, char*, int, unsigned short, unsigned short, int);
typedef void (* mb_error_handler_t)(struct mb_interpreter_t*, mb_error_e, char*, char*, int, unsigned short, unsigned short, int);
typedef int (* mb_print_func_t)(const char*, ...);
typedef int (* mb_input_func_t)(char*, int);
typedef int (* mb_import_handler_t)(struct mb_interpreter_t*, const char*);

View File

@ -92,7 +92,7 @@ enddef
' This is a brainfuck interpreter written with MY-BASIC
input "Input: ", cmd$
' Use a sample code?
' Input "hello" to use hello-world
if cmd$ = "hello" then
cmd$ = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."
endif

View File

@ -3,7 +3,7 @@
' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved.
' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
Class entity
class entity
var name = ""
var alive = true

View File

@ -101,9 +101,9 @@ extern "C" {
static struct mb_interpreter_t* bas = 0;
static jmp_buf _mem_failure_point;
static jmp_buf mem_failure_point;
#define _CHECK_MEM(__p) do { if(!(__p)) { longjmp(_mem_failure_point, 1); } } while(0)
#define _CHECK_MEM(__p) do { if(!(__p)) { longjmp(mem_failure_point, 1); } } while(0)
/* ========================================================} */
@ -185,8 +185,8 @@ static long alloc_bytes = 0;
static long in_pool_count = 0;
static long in_pool_bytes = 0;
static long _POOL_THRESHOLD_COUNT = 0;
static long _POOL_THRESHOLD_BYTES = 1024 * 1024 * 32;
static long POOL_THRESHOLD_COUNT = 0;
static long POOL_THRESHOLD_BYTES = 1024 * 1024 * 32;
#define _POOL_NODE_ALLOC(size) (((char*)malloc(sizeof(_pool_tag_t) + size)) + sizeof(_pool_tag_t))
#define _POOL_NODE_PTR(s) (s - sizeof(_pool_tag_t))
@ -211,10 +211,10 @@ static void _tidy_mem_pool(bool_t force) {
char* s = 0;
if(!force) {
if(_POOL_THRESHOLD_COUNT > 0 && in_pool_count < _POOL_THRESHOLD_COUNT)
if(POOL_THRESHOLD_COUNT > 0 && in_pool_count < POOL_THRESHOLD_COUNT)
return;
if(_POOL_THRESHOLD_BYTES > 0 && in_pool_bytes < _POOL_THRESHOLD_BYTES)
if(POOL_THRESHOLD_BYTES > 0 && in_pool_bytes < POOL_THRESHOLD_BYTES)
return;
}
@ -1193,7 +1193,7 @@ static bool_t _process_parameters(int argc, char* argv[]) {
#if _USE_MEM_POOL
if(memp)
_POOL_THRESHOLD_BYTES = atoi(memp);
POOL_THRESHOLD_BYTES = atoi(memp);
#else /* _USE_MEM_POOL */
mb_unrefvar(memp);
#endif /* _USE_MEM_POOL */
@ -1224,12 +1224,12 @@ static bool_t _process_parameters(int argc, char* argv[]) {
# define _OS "IOS"
#elif defined MB_OS_MAC
# define _OS "MACOS"
#elif defined MB_OS_UNIX
# define _OS "UNIX"
#elif defined MB_OS_LINUX
# define _OS "LINUX"
#elif defined MB_OS_ANDROID
# define _OS "ANDROID"
#elif defined MB_OS_LINUX
# define _OS "LINUX"
#elif defined MB_OS_UNIX
# define _OS "UNIX"
#else
# define _OS "UNKNOWN"
#endif /* MB_OS_WIN */
@ -1569,7 +1569,7 @@ int main(int argc, char* argv[]) {
atexit(_on_exit);
if(setjmp(_mem_failure_point)) {
if(setjmp(mem_failure_point)) {
_printf("Error: out of memory.\n");
exit(1);