This file is indexed.

/usr/share/axiom-20170501/src/algebra/SYMTAB.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
)abbrev domain SYMTAB SymbolTable
++ Author: Mike Dewar
++ Date Created:  October 1992
++ Date Last Updated: 12 July 1994
++ Description:
++ Create and manipulate a symbol table for generated FORTRAN code

SymbolTable() : SIG == CODE where

  T   ==> Union(S:Symbol,P:Polynomial Integer)
  TL1 ==> List T
  TU  ==> Union(name:Symbol,bounds:TL1)
  TL  ==> List TU
  SEX ==> SExpression
  OFORM ==> OutputForm
  L   ==> List
  FSTU ==> Union(fst:FortranScalarType,void:"void")

  SIG ==> CoercibleTo OutputForm with

    coerce : $ -> Table(Symbol,FortranType)
      ++ coerce(x) returns a table view of x

    empty  : () -> $
      ++ empty() returns a new, empty symbol table

    declare! : (L Symbol,FortranType,$) -> FortranType
      ++ declare!(l,t,tab) creates new entrys in tab, declaring each of l 
      ++ to be of type t

    declare! : (Symbol,FortranType,$) -> FortranType
      ++ declare!(u,t,tab) creates a new entry in tab, declaring u to be of
      ++ type t

    fortranTypeOf : (Symbol,$) -> FortranType
      ++ fortranTypeOf(u,tab) returns the type of u in tab

    parametersOf: $ -> L Symbol
      ++ parametersOf(tab) returns a list of all the symbols declared in tab

    typeList : (FortranScalarType,$) -> TL
      ++ typeList(t,tab) returns a list of all the objects of type t in tab

    externalList : $ -> L Symbol
      ++ externalList(tab) returns a list of all the external symbols in tab

    typeLists : $ -> L TL
      ++ typeLists(tab) returns a list of lists of types of objects in tab

    newTypeLists : $ -> SEX
      ++ newTypeLists(x) is not documented

    printTypes: $ -> Void
      ++ printTypes(tab) produces FORTRAN type declarations from tab, on the
      ++ current FORTRAN output stream

    symbolTable: L Record(key:Symbol,entry:FortranType) -> $
      ++ symbolTable(l) creates a symbol table from the elements of l.

  CODE ==> add

    Rep := Table(Symbol,FortranType)

    coerce(t:$):OFORM ==
      coerce(t)$Rep

    coerce(t:$):Table(Symbol,FortranType) ==
      t pretend Table(Symbol,FortranType)

    symbolTable(l:L Record(key:Symbol,entry:FortranType)):$ ==
      table(l)$Rep

    empty():$ ==
      empty()$Rep

    parametersOf(tab:$):L(Symbol) ==
      keys(tab)

    declare!(name:Symbol,type:FortranType,tab:$):FortranType ==
      setelt(tab,name,type)$Rep
      type

    declare!(names:L Symbol,type:FortranType,tab:$):FortranType ==
      for name in names repeat setelt(tab,name,type)$Rep
      type

    fortranTypeOf(u:Symbol,tab:$):FortranType ==
      elt(tab,u)$Rep

    externalList(tab:$):L(Symbol) ==
     [u for u in keys(tab) | external? fortranTypeOf(u,tab)]

    typeList(type:FortranScalarType,tab:$):TL ==
      scalarList := []@TL
      arrayList  := []@TL
      for u in keys(tab)$Rep repeat
        uType : FortranType := fortranTypeOf(u,tab)
        sType : FSTU := scalarTypeOf(uType)
        if (sType case fst and (sType.fst)=type) then
          uDim : TL1 := [[v]$T for v in dimensionsOf(uType)]
          if empty? uDim then 
            scalarList := cons([u]$TU,scalarList) 
          else 
            arrayList := cons([cons([u],uDim)$TL1]$TU,arrayList)
      -- Scalars come first in case they are integers which are later
      -- used as an array dimension.
      append(scalarList,arrayList)

    typeList2(type:FortranScalarType,tab:$):TL ==
      tl := []@TL
      symbolType : Symbol := coerce(type)$FortranScalarType
      for u in keys(tab)$Rep repeat
        uType : FortranType := fortranTypeOf(u,tab)
        sType : FSTU := scalarTypeOf(uType)
        if (sType case fst and (sType.fst)=type) then
          uDim : TL1 := [[v]$T for v in dimensionsOf(uType)]
          tl := if empty? uDim then cons([u]$TU,tl)
                else cons([cons([u],uDim)$TL1]$TU,tl)
      empty? tl => tl
      cons([symbolType]$TU,tl)

    updateList(sType:SEX,name:SEX,lDims:SEX,tl:SEX):SEX ==
      l : SEX := ASSOC(sType,tl)$Lisp
      entry : SEX := if null?(lDims) then name else CONS(name,lDims)$Lisp
      null?(l) => CONS([sType,entry]$Lisp,tl)$Lisp
      RPLACD(l,CONS(entry,cdr l)$Lisp)$Lisp
      tl

    newTypeLists(tab:$):SEX ==
      tl := []$Lisp
      for u in keys(tab)$Rep repeat
        uType : FortranType := fortranTypeOf(u,tab)
        sType : FSTU := scalarTypeOf(uType)
        dims  : L Polynomial Integer := dimensionsOf uType
        lDims : L SEX := [convert(convert(v)@InputForm)@SEX for v in dims]
        lType : SEX := if sType case void 
          then convert(void::Symbol)@SEX 
          else coerce(sType.fst)$FortranScalarType
        tl := updateList(lType,convert(u)@SEX,convert(lDims)@SEX,tl)
      tl

    typeLists(tab:$):L(TL) ==
      fortranTypes := ["real"::FortranScalarType, _
             "double precision"::FortranScalarType, _
             "integer"::FortranScalarType, _
             "complex"::FortranScalarType, _
             "logical"::FortranScalarType, _
             "character"::FortranScalarType]@L(FortranScalarType)
      tl := []@L TL
      for u in fortranTypes repeat
        types : TL := typeList2(u,tab)
        if (not null types) then 
          tl := cons(types,tl)$(L TL)
      tl

    oForm2(w:T):OFORM ==
      w case S => w.S::OFORM
      w case P => w.P::OFORM

    oForm(v:TU):OFORM ==
      v case name => v.name::OFORM
      v case bounds =>
        ll : L OFORM := [oForm2(uu) for uu in v.bounds]
        ll :: OFORM

    outForm(t:TL):L OFORM ==
     [oForm(u) for u in t]

    printTypes(tab:$):Void ==
      -- It is important that INTEGER is the first element of this
      -- list since INTEGER symbols used in type declarations must
      -- be declared in advance.
      ft := ["integer"::FortranScalarType, _
             "real"::FortranScalarType, _
             "double precision"::FortranScalarType, _
             "complex"::FortranScalarType, _
             "logical"::FortranScalarType, _
             "character"::FortranScalarType]@L(FortranScalarType)
      for ty in ft repeat
        tl : TL := typeList(ty,tab)
        otl : L OFORM := outForm(tl)
        fortFormatTypes(ty::OFORM,otl)$Lisp
      el : L OFORM := [u::OFORM for u in externalList(tab)]
      fortFormatTypes("EXTERNAL"::OFORM,el)$Lisp
      void()$Void