diff options
author | Adrian Thurston <thurston@colm.net> | 2018-12-02 13:07:46 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2018-12-02 13:07:46 -0500 |
commit | 779a96e143c9aaccebd24f5de48dee04e46aeab6 (patch) | |
tree | f40c0e56edc71e7c2ff122d54622b52301747037 /src/bytecode.c | |
parent | c53140a12f434c08e01ef3c84cfd8456e6525531 (diff) | |
download | colm-779a96e143c9aaccebd24f5de48dee04e46aeab6.tar.gz |
make location file name and column available in Colm code
Diffstat (limited to 'src/bytecode.c')
-rw-r--r-- | src/bytecode.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index a0cfdfac..74d1a25f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -3093,25 +3093,49 @@ again: colm_tree_downref( prg, sp, tree ); break; } - case IN_GET_TOKEN_POS_R: { - debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_POS_R\n" ); + case IN_GET_TOKEN_FILE_R: { + debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_FILE_R\n" ); + tree_t *tree = vm_pop_tree(); + tree_t *str = 0; + if ( tree->tokdata->location ) { + const char *fn = tree->tokdata->location->name; + head_t *data = string_alloc_full( prg, fn, strlen(fn) ); + str = construct_string( prg, data ); + colm_tree_upref( prg, str ); + } + vm_push_tree( str ); + colm_tree_downref( prg, sp, tree ); + break; + } + case IN_GET_TOKEN_LINE_R: { + debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_LINE_R\n" ); tree_t *tree = vm_pop_tree(); value_t integer = 0; if ( tree->tokdata->location ) - integer = tree->tokdata->location->byte; + integer = tree->tokdata->location->line; vm_push_value( integer ); colm_tree_downref( prg, sp, tree ); break; } - case IN_GET_TOKEN_LINE_R: { - debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_LINE_R\n" ); + case IN_GET_TOKEN_COL_R: { + debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_COL_R\n" ); tree_t *tree = vm_pop_tree(); value_t integer = 0; if ( tree->tokdata->location ) - integer = tree->tokdata->location->line; + integer = tree->tokdata->location->column; + vm_push_value( integer ); + colm_tree_downref( prg, sp, tree ); + break; + } + case IN_GET_TOKEN_POS_R: { + debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_POS_R\n" ); + tree_t *tree = vm_pop_tree(); + value_t integer = 0; + if ( tree->tokdata->location ) + integer = tree->tokdata->location->byte; vm_push_value( integer ); colm_tree_downref( prg, sp, tree ); break; |