From 15f8eb3b5ec71296b6013df16a3da03f06990d80 Mon Sep 17 00:00:00 2001 From: paladin-t Date: Thu, 17 Dec 2015 15:52:57 +0800 Subject: [PATCH] +added support to evaluate a sub routine by an accessor in print statement. --- HISTORY | 3 +++ core/my_basic.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index bb326a5..331396d 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Dec. 17 2015 +Added support to evaluate a sub routine by an accessor in PRINT statement + Dec. 15 2015 Added a pair of mb_begin_class/mb_end_class functions Added an mb_get_value_by_name function diff --git a/core/my_basic.c b/core/my_basic.c index a8484c9..851a027 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -11772,7 +11772,7 @@ int _std_print(mb_interpreter_t* s, void** l) { int result = MB_FUNC_OK; _ls_node_t* ast = 0; _object_t* obj = 0; - + _object_t tmp; _object_t val_obj; _object_t* val_ptr = 0; @@ -11791,12 +11791,22 @@ int _std_print(mb_interpreter_t* s, void** l) { obj = (_object_t*)(ast->data); do { switch(obj->type) { + case _DT_VAR: + if(obj->data.variable->pathing) { + _execute_statement(s, &ast); + _MAKE_NIL(&tmp); + _public_value_to_internal_object(&s->running_context->intermediate_value, &tmp); + val_ptr = obj = &tmp; + if(ast) ast = ast->prev; + + goto _print; + } + /* Fall through */ case _DT_TYPE: /* Fall through */ case _DT_NIL: /* Fall through */ case _DT_INT: /* Fall through */ case _DT_REAL: /* Fall through */ case _DT_STRING: /* Fall through */ - case _DT_VAR: /* Fall through */ case _DT_ARRAY: /* Fall through */ #ifdef MB_ENABLE_CLASS case _DT_CLASS: /* Fall through */ @@ -11804,6 +11814,7 @@ int _std_print(mb_interpreter_t* s, void** l) { case _DT_FUNC: /* Fall through */ case _DT_ROUTINE: result = _calc_expression(s, &ast, &val_ptr); +_print: if(val_ptr->type == _DT_NIL) { _get_printer(s)(MB_NIL); } else if(val_ptr->type == _DT_INT) {