Annotation of researchv10dc/cmd/icon/ipl/source/image.icn, revision 1.1

1.1     ! root        1: #      IMAGE
        !             2: #
        !             3: #      Generalized image of Icon object
        !             4: #
        !             5: #      Ralph E. Griswold
        !             6: #
        !             7: #      Last modified 2/1/86
        !             8: #
        !             9: 
        !            10: procedure Image(x,done)
        !            11:    /done := table()
        !            12:    if match("record ",image(x)) then return rimage(x,done)
        !            13:    else return case type(x) of {
        !            14:       "list":  limage(x,done)
        !            15:       "table": timage(x,done)
        !            16:       "set":   simage(x,done)
        !            17:       default: image(x)
        !            18:       }
        !            19: end
        !            20: 
        !            21: #  list image
        !            22: #
        !            23: procedure limage(a,done)
        !            24:    static i
        !            25:    local s, tag
        !            26:    initial i := 0
        !            27:    if \done[a] then return done[a]
        !            28:    done[a] := tag := "L" || (i +:= 1)
        !            29:    if *a = 0 then s := tag || ":[]" else {
        !            30:       s := tag || ":["
        !            31:       every s ||:= Image(!a,done) || ","
        !            32:       s[-1] := "]"
        !            33:       }
        !            34:    return s
        !            35: end
        !            36: 
        !            37: #  record image
        !            38: #
        !            39: procedure rimage(x,done)
        !            40:    static i
        !            41:    local s, tag
        !            42:    initial i := 0
        !            43:    s := image(x)
        !            44:                                        #  might be record constructor
        !            45:    if match("record constructor ",s) then return s
        !            46:    if \done[x] then return done[x]
        !            47:    done[x] := tag := "R" || (i +:= 1)
        !            48:    s ?:=  (="record " & (":" || (tab(upto('(') + 1))))
        !            49:    if *x = 0 then s := tag || s || ")" else {
        !            50:       s := tag || s
        !            51:       every s ||:= Image(!x,done) || ","
        !            52:       s[-1] := ")"
        !            53:       }
        !            54:    return s
        !            55: end
        !            56: 
        !            57: # set image
        !            58: #
        !            59: procedure simage(S,done)
        !            60:    static i
        !            61:    local s, tag
        !            62:    initial i := 0
        !            63:    if \done[S] then return done[S]
        !            64:    done[S] := tag := "S" || (i +:= 1)
        !            65:    if *S = 0 then s := tag || ":[]" else {
        !            66:       s := tag || ":["
        !            67:       every s ||:= Image(!S,done) || ","
        !            68:       s[-1] := "]"
        !            69:       }
        !            70:    return s
        !            71: end
        !            72: 
        !            73: #  table image
        !            74: #
        !            75: procedure timage(t,done)
        !            76:    static i
        !            77:    local s, tag, a, a1
        !            78:    initial i := 0
        !            79:    if \done[t] then return done[t]
        !            80:    done[t] := tag := "T" || (i +:= 1)
        !            81:    if *t = 0 then s := tag || ":[]" else {
        !            82:       a := sort(t,3)
        !            83:       s := tag || ":["
        !            84:       while s ||:= Image(get(a),done) || "->" || Image(get(a),done) || ","
        !            85:       s[-1] := "]"
        !            86:       }
        !            87:    return s
        !            88: end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.