rre: add sys:name

FossilOrigin-Name: 0feb3a42a228affa95bf9885ff5d8fd13c48363bbcf48c3c00845aaac8c09a22
This commit is contained in:
crc 2019-03-06 17:22:56 +00:00
parent 36a8642fc5
commit 142fef596f
10 changed files with 70 additions and 38 deletions

View file

@ -98,6 +98,7 @@ June 2019.
- add `-u filename` startup parameter to allow selection of
image file
- add `image:save`
- add `sys:name`
### retro-compiler

View file

@ -1225,6 +1225,9 @@ Return the number of arguments passed to the program.
sys:argv D: n-s A: - F: -
Given an argument number, return the argument as a string.
sys:name D: -s A: - F: -
Return the filename of the program being run.
tab D: - A: - F: -
Display a tab (`ASCII:HT`)

View file

@ -407,6 +407,7 @@ store-next D: na-a A: - F: -
swap D: nm-mn A: - F: -
sys:argc D: -n A: - F: -
sys:argv D: n-s A: - F: -
sys:name D: -s A: - F: -
tab D: - A: - F: -
times D: nq- A: - F: -
times<with-index> D: nq- A: - F: -

View file

@ -2803,7 +2803,7 @@
<b>Float:</b> -</p>
</div>
<p>Copy a string to the pasteboard.</p>
<p><b>Class:</b> class:word | <b>Namespace:</b> pb\n | <b>Interface Layer:</b> iOS</p>
<p><b>Class:</b> class:word | <b>Namespace:</b> pb | <b>Interface Layer:</b> iOS</p>
<hr/>
<h1>pop</h1>
<div style='margin-left: 1em;'><p><b>Data:</b> -n<br>
@ -3569,6 +3569,14 @@
<p>Given an argument number, return the argument as a string.</p>
<p><b>Class:</b> class:word | <b>Namespace:</b> sys | <b>Interface Layer:</b> rre</p>
<hr/>
<h1>sys:name</h1>
<div style='margin-left: 1em;'><p><b>Data:</b> -s<br>
<b>Addr:</b> -<br>
<b>Float:</b> -</p>
</div>
<p>Return the filename of the program being run.</p>
<p><b>Class:</b> class:word | <b>Namespace:</b> sys | <b>Interface Layer:</b> rre</p>
<hr/>
<h1>tab</h1>
<div style='margin-left: 1em;'><p><b>Data:</b> -<br>
<b>Addr:</b> -<br>

View file

@ -3819,7 +3819,7 @@ pb:set
Copy a string to the pasteboard.
Class: class:word | Namespace: pb\n | Interface Layer: iOS
Class: class:word | Namespace: pb | Interface Layer: iOS
------------------------------------------------------------------------
pop
@ -4843,6 +4843,17 @@ Given an argument number, return the argument as a string.
Class: class:word | Namespace: sys | Interface Layer: rre
------------------------------------------------------------------------
sys:name
Data: -s
Addr: -
Float: -
Return the filename of the program being run.
Class: class:word | Namespace: sys | Interface Layer: rre
------------------------------------------------------------------------
tab
Data: -

View file

@ -732,13 +732,13 @@ handle each case.
~~~
:process-arguments
QUERY
'describe [ find-and-display-entry ] s:case
'export [ export-data ] s:case
'edit [ handle-edit ] s:case
'add [ add-word ] s:case
'delete [ delete-entry ] s:case
'serve [ server ] s:case
'missing [ display-missing ] s:case
'describe [ find-and-display-entry nl ] s:case
'export [ export-data ] s:case
'edit [ handle-edit ] s:case
'add [ add-word ] s:case
'delete [ delete-entry ] s:case
'serve [ server ] s:case
'missing [ display-missing ] s:case
drop show-help ;
~~~

View file

@ -189,10 +189,15 @@ void scripting_include() {
include_file(string_extract(stack_pop()), 0);
}
void scripting_name() {
stack_push(string_inject(sys_argv[1], stack_pop()));
}
Handler ScriptingActions[] = {
scripting_arg_count,
scripting_arg,
scripting_include
scripting_include,
scripting_name
};
void io_scripting_query() {

View file

@ -64,7 +64,8 @@ words we can use.
---reveal---
:sys:argc (-n) identify #0 @io:Scripting io:invoke ;
:sys:argv (n-s) s:empty swap identify #1 @io:Scripting io:invoke ;
:include (s-) identify #2 @io:Scripting io:invoke ;
:include (s-) identify #2 @io:Scripting io:invoke ;
:sys:name (-s) s:empty identify #3 @io:Scripting io:invoke ;
}}
~~~

View file

@ -1,6 +1,6 @@
#include <stdint.h>
int32_t ngaImageCells = 15185;
int32_t ngaImage[] = { 1793,15136,15163,15184,201906,0,10,1,10,2,10,3,10,4,10,5,10,6,10,
int32_t ngaImageCells = 15208;
int32_t ngaImage[] = { 1793,15159,15186,15207,201906,0,10,1,10,2,10,3,10,4,10,5,10,6,10,
7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,10,
17,10,18,10,19,10,20,10,21,10,22,10,23,10,24,10,25,10,26,10,
68223234,1,2575,85000450,1,656912,142,141,268505089,66,65,135205121,66,10,101384453,0,9,10,2049,59,
@ -9,7 +9,7 @@ int32_t ngaImage[] = { 1793,15136,15163,15184,201906,0,10,1,10,2,10,3,10,4,10,5,
108,1793,115,2049,115,117506307,0,108,0,524545,25,113,168820993,0,127,1642241,127,134283523,7,113,
1793,108,7,524545,2049,108,1793,108,16846593,127,142,141,1793,67,16846593,127,113,141,1793,67,
7,10,659713,1,659713,2,659713,3,17108737,3,2,524559,108,2049,108,2049,108,2049,122,168820998,
2,15163,1025,167841793,180,5,17826049,0,180,2,15,25,524546,165,134287105,181,96,2305,182,459023,
2,15186,1025,167841793,180,5,17826049,0,180,2,15,25,524546,165,134287105,181,96,2305,182,459023,
190,134287361,181,185,659201,180,2049,59,25,84152833,48,286458116,10,459014,205,184618754,45,25,16974851,-1,
168886532,1,134284289,1,214,134284289,0,205,660227,32,0,0,112,114,101,102,105,120,58,105,
0,285278479,231,7,2576,524546,82,1641217,1,167838467,228,2049,244,2049,240,524545,231,200,17826050,230,
@ -159,7 +159,7 @@ int32_t ngaImage[] = { 1793,15136,15163,15184,201906,0,10,1,10,2,10,3,10,4,10,5,
2065,10,1,3112,2049,2065,4,16,10,3093,3146,147,118,58,117,112,100,97,116,101,
45,117,115,105,110,103,0,4,1793,3153,15,4,8,10,1,3149,2049,2077,16,10,
3128,3167,147,99,111,112,121,0,1793,3176,1,59,2049,2065,2049,62,10,1,3169,2049,
2252,3,3,10,3159,3196,147,83,99,111,112,101,76,105,115,116,0,14763,14984,10,
2252,3,3,10,3159,3196,147,83,99,111,112,101,76,105,115,116,0,14786,15007,10,
3183,3205,147,123,123,0,2049,1570,2,1,3196,2049,62,16,10,3199,3230,147,45,45,
45,114,101,118,101,97,108,45,45,45,0,2049,1570,1,3196,2049,2908,16,10,3214,
3244,147,125,125,0,1,3196,2049,59,4,15,11,1793,3258,3841,3196,4097,2,10,1,
@ -738,25 +738,26 @@ int32_t ngaImage[] = { 1793,15136,15163,15184,201906,0,10,1,10,2,10,3,10,4,10,5,
14710,147,115,121,115,58,97,114,103,99,0,2049,14627,1,0,3841,14614,2049,8870,10,
14698,14731,147,115,121,115,58,97,114,103,118,0,2049,3678,4,2049,14627,1,1,3841,
14614,2049,8870,10,14719,14754,147,105,110,99,108,117,100,101,0,2049,14627,1,2,3841,
14614,2049,8870,10,14743,14773,134,78,111,69,99,104,111,0,0,14763,14785,147,118,101,
114,115,105,111,110,0,3841,4,1,100,20,2049,9003,1,46,2049,8939,2049,9003,10,
14774,14807,147,101,111,108,63,0,1793,14813,1,13,11,10,1,14809,1793,14821,1,10,
11,10,1,14817,1793,14829,1,32,11,10,1,14825,2049,2129,22,22,10,14799,14846,147,
118,97,108,105,100,63,0,2,2049,82,2049,2583,10,14836,14858,147,111,107,0,3841,
14773,2049,2720,25,3,2049,1806,1793,14881,2049,8952,2049,3697,79,107,32,0,1,14872,2049,
8989,10,1,14868,2049,73,10,14852,14899,147,99,104,101,99,107,45,101,111,102,0,
2,1793,14906,1,-1,11,10,1,14902,1793,14914,1,4,11,10,1,14910,2049,2092,22,
1793,14936,2049,3697,98,121,101,0,1,14923,2049,200,2049,161,15,8,10,1,14921,9,
10,14886,14952,147,99,104,101,99,107,45,98,115,0,2,1793,14959,1,8,11,10,
1,14955,1793,14967,1,127,11,10,1,14963,2049,2092,22,1793,14980,2049,3407,2049,3407,771,
10,1,14974,9,10,14940,14993,147,115,58,103,101,116,0,1793,15022,1,1025,2049,3475,
1793,15013,2049,14452,2,2049,3383,2049,14899,2049,14952,2049,14807,10,1,15001,2049,2223,2049,3349,
2049,3790,10,1,14995,2049,3499,10,14763,15037,147,98,97,110,110,101,114,0,3841,14773,
2049,2720,25,3,2049,3697,82,69,84,82,79,32,49,50,32,40,114,120,45,0,
1,15045,2049,8989,2049,14785,1,41,2049,8939,2049,8952,2049,1543,2049,9003,2049,3697,32,77,
65,88,44,32,84,73,66,32,64,32,49,48,50,53,44,32,72,101,97,112,
32,64,32,0,1,15077,2049,8989,2049,1835,2049,9003,2049,8952,10,15027,15121,147,98,121,
101,0,1,0,2049,12424,10,15114,15136,147,108,105,115,116,101,110,0,2049,14858,2049,
14993,2049,14846,1793,15149,2049,367,2049,14858,10,1,15144,1793,15155,3,10,1,15153,2049,67,
1,15138,7,10,15126,15177,147,105,109,97,103,101,58,115,97,118,101,0,1,1000,
2049,8896,2049,8870,10,0 };
14614,2049,8870,10,14743,14775,147,115,121,115,58,110,97,109,101,0,2049,3678,2049,14627,
1,3,3841,14614,2049,8870,10,14763,14796,134,78,111,69,99,104,111,0,0,14786,14808,
147,118,101,114,115,105,111,110,0,3841,4,1,100,20,2049,9003,1,46,2049,8939,
2049,9003,10,14797,14830,147,101,111,108,63,0,1793,14836,1,13,11,10,1,14832,1793,
14844,1,10,11,10,1,14840,1793,14852,1,32,11,10,1,14848,2049,2129,22,22,10,
14822,14869,147,118,97,108,105,100,63,0,2,2049,82,2049,2583,10,14859,14881,147,111,
107,0,3841,14796,2049,2720,25,3,2049,1806,1793,14904,2049,8952,2049,3697,79,107,32,0,
1,14895,2049,8989,10,1,14891,2049,73,10,14875,14922,147,99,104,101,99,107,45,101,
111,102,0,2,1793,14929,1,-1,11,10,1,14925,1793,14937,1,4,11,10,1,14933,
2049,2092,22,1793,14959,2049,3697,98,121,101,0,1,14946,2049,200,2049,161,15,8,10,
1,14944,9,10,14909,14975,147,99,104,101,99,107,45,98,115,0,2,1793,14982,1,
8,11,10,1,14978,1793,14990,1,127,11,10,1,14986,2049,2092,22,1793,15003,2049,3407,
2049,3407,771,10,1,14997,9,10,14963,15016,147,115,58,103,101,116,0,1793,15045,1,
1025,2049,3475,1793,15036,2049,14452,2,2049,3383,2049,14922,2049,14975,2049,14830,10,1,15024,2049,
2223,2049,3349,2049,3790,10,1,15018,2049,3499,10,14786,15060,147,98,97,110,110,101,114,
0,3841,14796,2049,2720,25,3,2049,3697,82,69,84,82,79,32,49,50,32,40,114,
120,45,0,1,15068,2049,8989,2049,14808,1,41,2049,8939,2049,8952,2049,1543,2049,9003,2049,
3697,32,77,65,88,44,32,84,73,66,32,64,32,49,48,50,53,44,32,72,
101,97,112,32,64,32,0,1,15100,2049,8989,2049,1835,2049,9003,2049,8952,10,15050,15144,
147,98,121,101,0,1,0,2049,12424,10,15137,15159,147,108,105,115,116,101,110,0,
2049,14881,2049,15016,2049,14869,1793,15172,2049,367,2049,14881,10,1,15167,1793,15178,3,10,1,
15176,2049,67,1,15161,7,10,15149,15200,147,105,109,97,103,101,58,115,97,118,101,
0,1,1000,2049,8896,2049,8870,10,0 };

View file

@ -323,7 +323,7 @@ over nm-nmn - - Put a copy of n over m. class:word {n/a} {n/a} global all
parse-until q-s - - Read input from stdin (via `c:get`) until the returned character is matched by the quote. Returns a string. class:word :read-until-period (-s)\n [ $. eq? ] parse-until ; {n/a} all rre
pb:get a- - - Copy a string from the pasteboard to the specified address. class:word {n/a} {n/a} pb iOS {n/a}
pb:length -n - - Return the length of the string on the pasteboard. class:word {n/a} pb pb iOS
pb:set s- - - Copy a string to the pasteboard. class:word {n/a} {n/a} pb\n iOS
pb:set s- - - Copy a string to the pasteboard. class:word {n/a} {n/a} pb iOS
pop -n n- - Move a value from the return stack to the data stack. class:macro {n/a} {n/a} global all
prefix:! ns- - - Store a value into a variable. Store a value into the named variable. Compile the code to store a value into a named variable. class:macro {n/a} {n/a} prefix all
prefix:" s-s - - Process token as a string. Keep string as permanent. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Keep string as permanent. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition. class:macro {n/a} {n/a} prefix all
@ -407,6 +407,7 @@ store-next na-a - - Store a value into the specified address and return the next
swap nm-mn - - Exchange the position of the top two items on the stack class:primitive {n/a} {n/a} global all
sys:argc -n - - Return the number of arguments passed to the program. class:word {n/a} {n/a} sys rre
sys:argv n-s - - Given an argument number, return the argument as a string. class:word {n/a} {n/a} sys rre
sys:name -s - - Return the filename of the program being run. class:word {n/a} {n/a} sys rre
tab - - - Display a tab (`ASCII:HT`) class:word {n/a} {n/a} global all
times nq- - - Run the specified quote the specified number of times. class:word #12 [ $- c:put ] times {n/a} global all
times<with-index> nq- - - Run a quote the specified number of times, tracking the loop index in `I`. class:word {n/a} {n/a} global all

Can't render this file because it contains an unexpected character in line 57 and column 55.