1*46439007SCharles.ForsythAlphabet: module { 2*46439007SCharles.Forsyth PATH: con "/dis/alphabet/alphabet.dis"; 3*46439007SCharles.Forsyth ONDEMAND, CHECK: con 1<<iota; 4*46439007SCharles.Forsyth 5*46439007SCharles.Forsyth init: fn(); 6*46439007SCharles.Forsyth copy: fn(): Alphabet; 7*46439007SCharles.Forsyth quit: fn(); 8*46439007SCharles.Forsyth loadtypeset: fn(qname: string, c: chan of ref Proxy->Typescmd[ref Value], errorc: chan of string): string; 9*46439007SCharles.Forsyth declare: fn(qname: string, sig: string, flags: int): string; 10*46439007SCharles.Forsyth undeclare: fn(name: string): string; 11*46439007SCharles.Forsyth importmodule: fn(qname: string): string; 12*46439007SCharles.Forsyth importtype: fn(qname: string): string; 13*46439007SCharles.Forsyth importvalue: fn(v: ref Value, qname: string): (ref Value, string); 14*46439007SCharles.Forsyth autoconvert: fn(src, dst: string, transform: ref Sh->Cmd, errorc: chan of string): string; 15*46439007SCharles.Forsyth define: fn(name: string, expr: ref Sh->Cmd, errorc: chan of string): string; 16*46439007SCharles.Forsyth setautodeclare: fn(on: int); 17*46439007SCharles.Forsyth 18*46439007SCharles.Forsyth Decltypeset: adt { 19*46439007SCharles.Forsyth name: string; 20*46439007SCharles.Forsyth alphabet: string; 21*46439007SCharles.Forsyth types: array of string; 22*46439007SCharles.Forsyth mods: array of (string, string); 23*46439007SCharles.Forsyth }; 24*46439007SCharles.Forsyth Declarations: adt { 25*46439007SCharles.Forsyth typesets: array of Decltypeset; 26*46439007SCharles.Forsyth defs: array of (string, string); 27*46439007SCharles.Forsyth }; 28*46439007SCharles.Forsyth# getdecls: fn(): ref Declarations; 29*46439007SCharles.Forsyth# getexprdecls: fn(e: ref Sh->Cmd): ref Declarations; 30*46439007SCharles.Forsyth# declcompat: fn(d0, d1: ref Declarations): int; 31*46439007SCharles.Forsyth 32*46439007SCharles.Forsyth getmodule: fn(name: string): (string, string, ref Sh->Cmd); 33*46439007SCharles.Forsyth gettypesets: fn(): list of string; 34*46439007SCharles.Forsyth getmodules: fn(): list of string; 35*46439007SCharles.Forsyth gettypesetmodules: fn(tsname: string): chan of string; 36*46439007SCharles.Forsyth gettypes: fn(typeset: string): list of string; 37*46439007SCharles.Forsyth getautoconversions: fn(): list of (string, string, ref Sh->Cmd); 38*46439007SCharles.Forsyth typecompat: fn(t0, t1: string): (int, string); 39*46439007SCharles.Forsyth show: fn(); 40*46439007SCharles.Forsyth 41*46439007SCharles.Forsyth mkqname: fn(typeset, name: string): string; 42*46439007SCharles.Forsyth canon: fn(qname: string): string; 43*46439007SCharles.Forsyth splitqname: fn(qname: string): (string, string); 44*46439007SCharles.Forsyth parse: fn(expr: string): (ref Sh->Cmd, string); 45*46439007SCharles.Forsyth 46*46439007SCharles.Forsyth eval: fn(expr: ref Sh->Cmd, 47*46439007SCharles.Forsyth drawctxt: ref Draw->Context, 48*46439007SCharles.Forsyth args: list of ref Value): string; 49*46439007SCharles.Forsyth eval0: fn(expr: ref Sh->Cmd, 50*46439007SCharles.Forsyth dsttype: string, 51*46439007SCharles.Forsyth drawctxt: ref Draw->Context, 52*46439007SCharles.Forsyth report: ref Reports->Report, 53*46439007SCharles.Forsyth errorc: chan of string, 54*46439007SCharles.Forsyth args: list of ref Value, 55*46439007SCharles.Forsyth vc: chan of ref Value); 56*46439007SCharles.Forsyth rewrite: fn(expr: ref Sh->Cmd, dsttype: string, 57*46439007SCharles.Forsyth errorc: chan of string): (ref Sh->Cmd, string); 58*46439007SCharles.Forsyth 59*46439007SCharles.Forsyth Value: adt { 60*46439007SCharles.Forsyth free: fn(v: self ref Value, used: int); 61*46439007SCharles.Forsyth dup: fn(v: self ref Value): ref Value; 62*46439007SCharles.Forsyth gets: fn(v: self ref Value): string; 63*46439007SCharles.Forsyth isstring: fn(v: self ref Value): int; 64*46439007SCharles.Forsyth type2s: fn(tc: int): string; 65*46439007SCharles.Forsyth typec: fn(v: self ref Value): int; 66*46439007SCharles.Forsyth typename: fn(v: self ref Value): string; 67*46439007SCharles.Forsyth 68*46439007SCharles.Forsyth c: fn(v: self ref Value): ref Value.Vc; 69*46439007SCharles.Forsyth s: fn(v: self ref Value): ref Value.Vs; 70*46439007SCharles.Forsyth r: fn(v: self ref Value): ref Value.Vr; 71*46439007SCharles.Forsyth f: fn(v: self ref Value): ref Value.Vf; 72*46439007SCharles.Forsyth w: fn(v: self ref Value): ref Value.Vw; 73*46439007SCharles.Forsyth d: fn(v: self ref Value): ref Value.Vd; 74*46439007SCharles.Forsyth z: fn(v: self ref Value): ref Value.Vz; 75*46439007SCharles.Forsyth 76*46439007SCharles.Forsyth pick{ 77*46439007SCharles.Forsyth Vc => 78*46439007SCharles.Forsyth i: ref Sh->Cmd; 79*46439007SCharles.Forsyth Vs => 80*46439007SCharles.Forsyth i: string; 81*46439007SCharles.Forsyth Vr => 82*46439007SCharles.Forsyth i: chan of string; 83*46439007SCharles.Forsyth Vf or 84*46439007SCharles.Forsyth Vw => 85*46439007SCharles.Forsyth i: chan of ref Sys->FD; 86*46439007SCharles.Forsyth Vd => 87*46439007SCharles.Forsyth i: Datachan; 88*46439007SCharles.Forsyth Vz => 89*46439007SCharles.Forsyth i: Proxyval; # a proxy for the actual value, held by another process 90*46439007SCharles.Forsyth } 91*46439007SCharles.Forsyth }; 92*46439007SCharles.Forsyth 93*46439007SCharles.Forsyth Proxyval: adt { 94*46439007SCharles.Forsyth typec: int; 95*46439007SCharles.Forsyth id: int; 96*46439007SCharles.Forsyth }; 97*46439007SCharles.Forsyth 98*46439007SCharles.Forsyth Datachan: adt { 99*46439007SCharles.Forsyth d: chan of array of byte; 100*46439007SCharles.Forsyth stop: chan of int; 101*46439007SCharles.Forsyth }; 102*46439007SCharles.Forsyth}; 103*46439007SCharles.Forsyth 104*46439007SCharles.ForsythMainmodule: module { 105*46439007SCharles.Forsyth typesig: fn(): string; 106*46439007SCharles.Forsyth init: fn(); 107*46439007SCharles.Forsyth quit: fn(); 108*46439007SCharles.Forsyth run: fn(ctxt: ref Draw->Context, r: ref Reports->Report, errorc: chan of string, 109*46439007SCharles.Forsyth opts: list of (int, list of ref Alphabet->Value), args: list of ref Alphabet->Value): ref Alphabet->Value; 110*46439007SCharles.Forsyth}; 111*46439007SCharles.Forsyth 112*46439007SCharles.Forsyth# evaluate an expression 113*46439007SCharles.ForsythEval: module { 114*46439007SCharles.Forsyth PATH: con "/dis/alphabet/eval.dis"; 115*46439007SCharles.Forsyth init: fn(); 116*46439007SCharles.Forsyth 117*46439007SCharles.Forsyth Context: adt[V, M, Ectxt] 118*46439007SCharles.Forsyth for { 119*46439007SCharles.Forsyth V => 120*46439007SCharles.Forsyth dup: fn(t: self V): V; 121*46439007SCharles.Forsyth free: fn(v: self V, used: int); 122*46439007SCharles.Forsyth isstring: fn(v: self V): int; 123*46439007SCharles.Forsyth gets: fn(t: self V): string; 124*46439007SCharles.Forsyth type2s: fn(tc: int): string; 125*46439007SCharles.Forsyth typec: fn(t: self V): int; 126*46439007SCharles.Forsyth M => 127*46439007SCharles.Forsyth find: fn(c: Ectxt, s: string): (M, string); 128*46439007SCharles.Forsyth typesig: fn(m: self M): string; 129*46439007SCharles.Forsyth run: fn(m: self M, c: Ectxt, errorc: chan of string, 130*46439007SCharles.Forsyth opts: list of (int, list of V), args: list of V): V; 131*46439007SCharles.Forsyth mks: fn(c: Ectxt, s: string): V; 132*46439007SCharles.Forsyth mkc: fn(c: Ectxt, cmd: ref Sh->Cmd): V; 133*46439007SCharles.Forsyth typename2c: fn(s: string): int; 134*46439007SCharles.Forsyth cvt: fn(c: Ectxt, v: V, tc: int, errorc: chan of string): V; 135*46439007SCharles.Forsyth } 136*46439007SCharles.Forsyth { 137*46439007SCharles.Forsyth eval: fn( 138*46439007SCharles.Forsyth expr: ref Sh->Cmd, 139*46439007SCharles.Forsyth ctxt: Ectxt, 140*46439007SCharles.Forsyth errorc: chan of string, 141*46439007SCharles.Forsyth args: list of V 142*46439007SCharles.Forsyth ): V; 143*46439007SCharles.Forsyth }; 144*46439007SCharles.Forsyth cmdusage: fn[V](nil: V, sig: string): string 145*46439007SCharles.Forsyth for { 146*46439007SCharles.Forsyth V => 147*46439007SCharles.Forsyth type2s: fn(tc: int): string; 148*46439007SCharles.Forsyth }; 149*46439007SCharles.Forsyth usage2sig: fn[V](nil: V, u: string): (string, string) 150*46439007SCharles.Forsyth for{ 151*46439007SCharles.Forsyth V => 152*46439007SCharles.Forsyth typename2c: fn(s: string): int; 153*46439007SCharles.Forsyth }; 154*46439007SCharles.Forsyth blocksig: fn[M, Ectxt](nil: M, ctxt: Ectxt, c: ref Sh->Cmd): (string, string) 155*46439007SCharles.Forsyth for{ 156*46439007SCharles.Forsyth M => 157*46439007SCharles.Forsyth typename2c: fn(s: string): int; 158*46439007SCharles.Forsyth find: fn(c: Ectxt, s: string): (M, string); 159*46439007SCharles.Forsyth typesig: fn(m: self M): string; 160*46439007SCharles.Forsyth }; 161*46439007SCharles.Forsyth typecompat: fn(t0, t1: string): int; 162*46439007SCharles.Forsyth splittype: fn(t: string): (int, string, string); 163*46439007SCharles.Forsyth}; 164*46439007SCharles.Forsyth 165*46439007SCharles.ForsythExtvalues: module { 166*46439007SCharles.Forsyth PATH: con "/dis/alphabet/extvalues.dis"; 167*46439007SCharles.Forsyth Values: adt[V] { 168*46439007SCharles.Forsyth lock: chan of int; 169*46439007SCharles.Forsyth v: array of (int, V); 170*46439007SCharles.Forsyth freeids: list of int; 171*46439007SCharles.Forsyth new: fn(): ref Values[V]; 172*46439007SCharles.Forsyth add: fn(vals: self ref Values, v: V): int; 173*46439007SCharles.Forsyth inc: fn(vals: self ref Values, id: int); 174*46439007SCharles.Forsyth del: fn(vals: self ref Values, id: int); 175*46439007SCharles.Forsyth }; 176*46439007SCharles.Forsyth}; 177*46439007SCharles.Forsyth 178*46439007SCharles.Forsyth# generic proxy implementation: 179*46439007SCharles.ForsythProxy: module { 180*46439007SCharles.Forsyth PATH: con "/dis/alphabet/proxy.dis"; 181*46439007SCharles.Forsyth 182*46439007SCharles.Forsyth # operators on a type system 183*46439007SCharles.Forsyth Typescmd: adt[V] { 184*46439007SCharles.Forsyth pick { 185*46439007SCharles.Forsyth Load => 186*46439007SCharles.Forsyth cmd: string; 187*46439007SCharles.Forsyth reply: chan of (chan of ref Modulecmd[V], string); 188*46439007SCharles.Forsyth Dup => 189*46439007SCharles.Forsyth v: V; 190*46439007SCharles.Forsyth reply: chan of V; 191*46439007SCharles.Forsyth Free => 192*46439007SCharles.Forsyth v: V; 193*46439007SCharles.Forsyth used: int; 194*46439007SCharles.Forsyth reply: chan of int; 195*46439007SCharles.Forsyth Alphabet => 196*46439007SCharles.Forsyth reply: chan of string; 197*46439007SCharles.Forsyth Type2s => 198*46439007SCharles.Forsyth tc: int; 199*46439007SCharles.Forsyth reply: chan of string; 200*46439007SCharles.Forsyth Loadtypes => 201*46439007SCharles.Forsyth name: string; 202*46439007SCharles.Forsyth reply: chan of (chan of ref Typescmd[V], string); 203*46439007SCharles.Forsyth Modules => 204*46439007SCharles.Forsyth reply: chan of string; 205*46439007SCharles.Forsyth } 206*46439007SCharles.Forsyth }; 207*46439007SCharles.Forsyth 208*46439007SCharles.Forsyth # proxy for a loaded module. 209*46439007SCharles.Forsyth Modulecmd: adt[V] { 210*46439007SCharles.Forsyth pick { 211*46439007SCharles.Forsyth Typesig => 212*46439007SCharles.Forsyth reply: chan of string; 213*46439007SCharles.Forsyth Run => 214*46439007SCharles.Forsyth ctxt: ref Draw->Context; 215*46439007SCharles.Forsyth report: ref Reports->Report; 216*46439007SCharles.Forsyth errorc: chan of string; 217*46439007SCharles.Forsyth# stopc: chan of int; 218*46439007SCharles.Forsyth opts: list of (int, list of V); 219*46439007SCharles.Forsyth args: list of V; 220*46439007SCharles.Forsyth reply: chan of V; 221*46439007SCharles.Forsyth } 222*46439007SCharles.Forsyth }; 223*46439007SCharles.Forsyth 224*46439007SCharles.Forsyth proxy: fn[Ctxt,Cvt,M,V,EV](ctxt: Ctxt): ( 225*46439007SCharles.Forsyth chan of ref Proxy->Typescmd[EV], 226*46439007SCharles.Forsyth chan of (string, chan of ref Proxy->Typescmd[V]) 227*46439007SCharles.Forsyth ) for { 228*46439007SCharles.Forsyth M => 229*46439007SCharles.Forsyth typesig: fn(m: self M): string; 230*46439007SCharles.Forsyth run: fn(m: self M, ctxt: ref Draw->Context, r: ref Reports->Report, errorc: chan of string, 231*46439007SCharles.Forsyth opts: list of (int, list of V), args: list of V): V; 232*46439007SCharles.Forsyth quit: fn(m: self M); 233*46439007SCharles.Forsyth Ctxt => 234*46439007SCharles.Forsyth loadtypes: fn(ctxt: self Ctxt, name: string): (chan of ref Proxy->Typescmd[V], string); 235*46439007SCharles.Forsyth type2s: fn(ctxt: self Ctxt, tc: int): string; 236*46439007SCharles.Forsyth alphabet: fn(ctxt: self Ctxt): string; 237*46439007SCharles.Forsyth modules: fn(ctxt: self Ctxt, r: chan of string); 238*46439007SCharles.Forsyth find: fn(ctxt: self Ctxt, s: string): (M, string); 239*46439007SCharles.Forsyth getcvt: fn(ctxt: self Ctxt): Cvt; 240*46439007SCharles.Forsyth Cvt => 241*46439007SCharles.Forsyth int2ext: fn(cvt: self Cvt, v: V): EV; 242*46439007SCharles.Forsyth ext2int: fn(cvt: self Cvt, ev: EV): V; 243*46439007SCharles.Forsyth free: fn(cvt: self Cvt, v: EV, used: int); 244*46439007SCharles.Forsyth dup: fn(cvt: self Cvt, v: EV): EV; 245*46439007SCharles.Forsyth }; 246*46439007SCharles.Forsyth}; 247