Find an attribute via dynamic scoping up enclosing scope chain. Only look for a dictionary definition if the attribute is not found, so attributes sent in to a template override dictionary names. Return ST#EMPTY_ATTR if found definition but no value.
(InstanceScope scope, String name)
| 1192 | */ |
| 1193 | |
| 1194 | public Object getAttribute(InstanceScope scope, String name) { |
| 1195 | InstanceScope current = scope; |
| 1196 | while ( current!=null ) { |
| 1197 | ST p = current.st; |
| 1198 | FormalArgument localArg = null; |
| 1199 | if ( p.impl.formalArguments!=null ) localArg = p.impl.formalArguments.get(name); |
| 1200 | if ( localArg!=null ) { |
| 1201 | Object o = p.locals[localArg.index]; |
| 1202 | return o; |
| 1203 | } |
| 1204 | current = current.parent; // look up enclosing scope chain |
| 1205 | } |
| 1206 | // got to root scope and no definition, try dictionaries in group and up |
| 1207 | final ST self = scope.st; |
| 1208 | STGroup g = self.impl.nativeGroup; |
| 1209 | Object o = getDictionary(g, name); |
| 1210 | if ( o!=null ) return o; |
| 1211 | |
| 1212 | // not found, report unknown attr |
| 1213 | throw new STNoSuchAttributeException(name, scope); |
| 1214 | } |
| 1215 | |
| 1216 | public Object getDictionary(STGroup g, String name) { |
| 1217 | if ( g.isDictionary(name) ) { |
no test coverage detected