Skip to content

Commit

Permalink
fixed #265: supported $pwd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kray-G committed Apr 8, 2021
1 parent 42408b3 commit 2592351
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/ast_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <kxoptimizer.h>

#define KX_ENV_VAR ("$env")
#define KX_PWD_VAR ("$pwd")
#define KXN_ISOBJ(x) (((x) == KX_OBJ_T) || ((x) == KX_ARY_T))

KHASH_MAP_INIT_STR(enum_value, int)
Expand Down Expand Up @@ -670,6 +671,19 @@ LOOP_HEAD:;
node->type = KXST_EXPRLIST;
}
break;
} else if (node && node->type == KXOP_VAR && !strcmp(node->value.s, KX_PWD_VAR)) {
if (actx->lvalue) {
kx_yyerror_line("$pwd can not be lvalue", node->file, node->line);
} else {
node->lhs = kx_gen_bexpr_object(KXOP_CALL,
kx_gen_bexpr_object(KXOP_IDX, kx_gen_var_object("System", KX_OBJ_T), kx_gen_str_object("cwd")),
NULL
);
analyze_ast(ctx, node->lhs, actx);
node->rhs = NULL;
node->type = KXST_EXPRLIST;
}
break;
} else {
if (!strcmp(node->value.s, "__FUNC__")) {
if (actx->func) {
Expand Down

0 comments on commit 2592351

Please sign in to comment.