1Command: module 2{ 3 PATH: con "/dis/sh.dis"; 4 5 init: fn(ctxt: ref Draw->Context, argv: list of string); 6}; 7 8Sh: module 9{ 10 PATH: con "/dis/sh.dis"; 11 initialise: fn(); 12 init: fn(ctxt: ref Draw->Context, argv: list of string); 13 system: fn(drawctxt: ref Draw->Context, cmd: string): string; 14 run: fn(drawctxt: ref Draw->Context, argv: list of string): string; 15 parse: fn(s: string): (ref Cmd, string); 16 cmd2string: fn(c: ref Cmd): string; 17 18 Context: adt { 19 new: fn(drawcontext: ref Draw->Context): ref Context; 20 get: fn(c: self ref Context, name: string): list of ref Listnode; 21 set: fn(c: self ref Context, name: string, val: list of ref Listnode); 22 setlocal: fn(c: self ref Context, name: string, val: list of ref Listnode); 23 envlist: fn(c: self ref Context): list of (string, list of ref Listnode); 24 push: fn(c: self ref Context); 25 pop: fn(c: self ref Context); 26 copy: fn(c: self ref Context, copyenv: int): ref Context; 27 run: fn(c: self ref Context, args: list of ref Listnode, last: int): string; 28 addmodule: fn(c: self ref Context, name: string, mod: Shellbuiltin); 29 addbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 30 removebuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 31 addsbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 32 removesbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 33 fail: fn(c: self ref Context, ename, msg: string); 34 options: fn(c: self ref Context): int; 35 setoptions: fn(c: self ref Context, flags, on: int): int; 36 INTERACTIVE, VERBOSE, EXECPRINT, ERROREXIT: con 1 << iota; 37 38 env: ref Environment; 39 waitfd: ref Sys->FD; 40 drawcontext: ref Draw->Context; 41 keepfds: list of int; 42 }; 43 44 list2stringlist: fn(nl: list of ref Listnode): list of string; 45 stringlist2list: fn(sl: list of string): list of ref Listnode; 46 quoted: fn(val: list of ref Listnode, quoteblocks: int): string; 47 48 initbuiltin: fn(c: ref Context, sh: Sh): string; 49 whatis: fn(nil: ref Sh->Context, nil: Sh, nil: string, nil: int): string; 50 runbuiltin: fn(c: ref Context, sh: Sh, cmd: list of ref Listnode, last: int): string; 51 runsbuiltin: fn(c: ref Context, sh: Sh, cmd: list of ref Listnode): list of ref Listnode; 52 getself: fn(): Shellbuiltin; 53 Cmd: type Node; 54 Node: adt { 55 ntype: int; 56 left, right: ref Node; 57 word: string; 58 redir: ref Redir; 59 }; 60 Redir: adt { 61 rtype: int; 62 fd1, fd2: int; 63 }; 64 Var: adt { 65 name: string; 66 val: list of ref Listnode; 67 flags: int; 68 CHANGED, NOEXPORT: con (1 << iota); 69 }; 70 Environment: adt { 71 sbuiltins: ref Builtins; 72 builtins: ref Builtins; 73 bmods: list of (string, Shellbuiltin); 74 localenv: ref Localenv; 75 }; 76 Localenv: adt { 77 vars: array of list of ref Var; 78 pushed: ref Localenv; 79 flags: int; 80 }; 81 Listnode: adt { 82 cmd: ref Node; 83 word: string; 84 }; 85 Builtins: adt { 86 ba: array of (string, list of Shellbuiltin); 87 n: int; 88 }; 89 # node types 90 n_BLOCK, n_VAR, n_BQ, n_BQ2, n_REDIR, 91 n_DUP, n_LIST, n_SEQ, n_CONCAT, n_PIPE, n_ADJ, 92 n_WORD, n_NOWAIT, n_SQUASH, n_COUNT, 93 n_ASSIGN, n_LOCAL: con iota; 94 GLOB: con 1; 95}; 96 97Shellbuiltin: module { 98 initbuiltin: fn(c: ref Sh->Context, sh: Sh): string; 99 runbuiltin: fn(c: ref Sh->Context, sh: Sh, 100 cmd: list of ref Sh->Listnode, last: int): string; 101 runsbuiltin: fn(c: ref Sh->Context, sh: Sh, 102 cmd: list of ref Sh->Listnode): list of ref Sh->Listnode; 103 BUILTIN, SBUILTIN, OTHER: con iota; 104 whatis: fn(c: ref Sh->Context, sh: Sh, name: string, wtype: int): string; 105 getself: fn(): Shellbuiltin; 106}; 107