|
|
1.1 ! root 1: (* Copyright 1989 by AT&T Bell Laboratories *) ! 2: (* lambda.sml *) ! 3: ! 4: signature LAMBDA = sig ! 5: ! 6: structure Access: ACCESS ! 7: structure Basics: BASICS ! 8: ! 9: type primop sharing type primop = Access.primop ! 10: ! 11: datatype con ! 12: = DATAcon of Basics.datacon ! 13: | INTcon of int ! 14: | REALcon of string ! 15: | STRINGcon of string ! 16: ! 17: datatype lexp ! 18: = VAR of Access.lvar ! 19: | FN of Access.lvar * lexp ! 20: | FIX of Access.lvar list * lexp list * lexp ! 21: | APP of lexp * lexp ! 22: | INT of int ! 23: | REAL of string ! 24: | STRING of string ! 25: | SWITCH of lexp * (con*lexp) list * lexp option ! 26: | RECORD of lexp list ! 27: | SELECT of int * lexp ! 28: | RAISE of lexp ! 29: | HANDLE of lexp * lexp ! 30: | PRIM of primop ! 31: ! 32: val CON : Basics.datacon * lexp -> lexp ! 33: val DECON : Basics.datacon * lexp -> lexp ! 34: ! 35: end ! 36: ! 37: structure Lambda : LAMBDA = struct ! 38: ! 39: structure Access = Access ! 40: structure Basics = Basics ! 41: open Access Basics ! 42: ! 43: type primop = Access.primop ! 44: ! 45: datatype con ! 46: = DATAcon of datacon ! 47: | INTcon of int ! 48: | REALcon of string ! 49: | STRINGcon of string ! 50: ! 51: datatype lexp ! 52: = VAR of lvar ! 53: | FN of lvar * lexp ! 54: | FIX of lvar list * lexp list * lexp ! 55: | APP of lexp * lexp ! 56: | INT of int ! 57: | REAL of string ! 58: | STRING of string ! 59: | SWITCH of lexp * (con*lexp) list * lexp option ! 60: | RECORD of lexp list ! 61: | SELECT of int * lexp ! 62: | RAISE of lexp ! 63: | HANDLE of lexp * lexp ! 64: | PRIM of primop ! 65: ! 66: fun trpath [i] = VAR i ! 67: | trpath (a::r) = SELECT(a, trpath r) ! 68: ! 69: fun CON (DATACON{rep=(TAGGED i),...},e) = RECORD[e,INT i] ! 70: | CON (DATACON{rep=TRANSPARENT,...},e) = e ! 71: | CON (DATACON{rep=TRANSU,...},e) = e ! 72: | CON (DATACON{rep=TRANSB,...},e) = e ! 73: | CON (DATACON{rep=REF,...},e) = APP(PRIM Access.P.makeref,e) ! 74: | CON (DATACON{rep=(VARIABLE(PATH p)),const=true,...},e) = trpath p ! 75: | CON (DATACON{rep=(VARIABLE(PATH p)),...},e) = RECORD[e, trpath p] ! 76: | CON (DATACON{rep=(CONSTANT i),...},e) = INT i ! 77: ! 78: fun DECON (DATACON{rep=(TAGGED _),...},e) = SELECT(0,e) ! 79: | DECON (DATACON{rep=TRANSPARENT,...},e) = e ! 80: | DECON (DATACON{rep=TRANSU,...},e) = e ! 81: | DECON (DATACON{rep=TRANSB,...},e) = e ! 82: | DECON (DATACON{rep=REF,...},e) = APP(PRIM Access.P.!,e) ! 83: | DECON (DATACON{rep=(VARIABLE _),...},e) = SELECT(0,e) ! 84: | DECON (DATACON{name,rep=r,...},e) = ! 85: (print (Symbol.name name); print " "; PrintBasics.printRep r; print "\n"; ! 86: ErrorMsg.impossible "DECON with bad constructor") ! 87: ! 88: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.