1 setup common environment: 2 3 $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH" 4 $ alias ucode="$UCODE_BIN" 5 6 $ for m in $BUILD_BIN_DIR/*.so; do 7 > ln -s "$m" "$(pwd)/$(basename $m)"; \ 8 > done 9 10 check that ucode provides exepected help: 11 12 $ ucode | sed 's/ucode-san/ucode/' 13 Usage: 14 ucode -h 15 ucode -e "expression" 16 ucode input.uc [input2.uc ...] 17 ucode -c [-s] [-o output.uc] input.uc [input2.uc ...] 18 19 -h 20 Help display this help. 21 22 -e "expression" 23 Execute the given expression as ucode program. 24 25 -p "expression" 26 Like `-e` but print the result of expression. 27 28 -t 29 Enable VM execution tracing. 30 31 -g interval 32 Perform periodic garbage collection every `interval` object 33 allocations. 34 35 -S 36 Enable strict mode. 37 38 -R 39 Process source file(s) as raw script code (default). 40 41 -T[flag,flag,...] 42 Process the source file(s) as templates, not as raw script code. 43 Supported flags: no-lstrip (don't strip leading whitespace before 44 block tags), no-rtrim (don't strip trailing newline after block tags). 45 46 -D [name=]value 47 Define global variable. If `name` is omitted, a JSON dictionary is 48 expected with each property becoming a global variable set to the 49 corresponding value. If `name` is specified, it is defined as global 50 variable set to `value` parsed as JSON (or the literal `value` string 51 if JSON parsing fails). 52 53 -F [name=]path 54 Like `-D` but reading the value from the file in `path`. The given 55 file must contain a single, well-formed JSON dictionary. 56 57 -U name 58 Undefine the given global variable name. 59 60 -l [name=]library 61 Preload the given `library`, optionally aliased to `name`. 62 63 -L pattern 64 Prepend given `pattern` to default library search paths. If the pattern 65 contains no `*`, it is added twice, once with `/*.so` and once with 66 `/*.uc` appended to it. 67 68 -c[flag,flag,...] 69 Compile the given source file(s) to bytecode instead of executing them. 70 Supported flags: no-interp (omit interpreter line), interp=... (over- 71 ride interpreter line with ...), dynlink=... (force import from ... to 72 be treated as shared extensions loaded at runtime), module (build load- 73 able library). 74 75 -o path 76 Output file path when compiling. If omitted, the compiled byte code 77 is written to `./uc.out`. Only meaningful in conjunction with `-c`. 78 79 -s 80 Omit (strip) debug information when compiling files. 81 Only meaningful in conjunction with `-c`. 82 83 -x[expr] 84 Start program in interactive debugger. If given, stop at the location 85 described by `expr` (a function name, `path:line[:offset]`, or a ucode 86 expression evaluating to a function - the same grammar the `break` 87 debugger CLI command accepts) instead of the first instruction. 88 89 -X[expr] 90 Enable debugger infrastructure (SIGUSR1 break, uloop) without 91 launching the interactive debugger automatically. If given, `expr` is 92 resolved the same way as for `-x` and a breakpoint is installed at 93 that location; once hit, execution pauses and waits for a remote 94 debugger to attach, the same way the SIGUSR1 break does. 95 96 97 98 99 check that ucode prints greetings: 100 101 $ ucode -e "print('hello world')" 102 hello world (no-eol) 103 104 check that ucode provides proper error messages: 105 106 $ touch lib.uc; ucode -l lib 107 Require either -e/-p expression or source file 108 [1] 109 110 $ ucode -l foo -e ' ' 111 Runtime error: No module named 'foo' could be found 112 113 [1] 114 115 $ touch moo; ucode -l foo moo 116 Runtime error: No module named 'foo' could be found 117 118 [1] 119 120 check that ucode can load fs module: 121 122 $ ucode -l fs 123 Require either -e/-p expression or source file 124 [1] 125 126 $ ucode -l fs -e ' ' 127 128 $ touch moo; ucode -l fs moo
This page was automatically generated by LXR 0.3.1. • OpenWrt