MCPcopy Create free account
hub / github.com/antlr/codebuff / getAttribute

Method getAttribute

output/java/1.4.17/Interpreter.java:1220–1240  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1218 */
1219
1220 public Object getAttribute(InstanceScope scope, String name) {
1221 InstanceScope current = scope;
1222 while ( current !=null ) {
1223 ST p = current.st;
1224 FormalArgument localArg = null;
1225 if ( p.impl.formalArguments!=null ) localArg = p.impl.formalArguments.get(name);
1226 if ( localArg !=null ) {
1227 Object o = p.locals[localArg.index];
1228 return o;
1229 }
1230 current = current.parent; // look up enclosing scope chain
1231 }
1232 // got to root scope and no definition, try dictionaries in group and up
1233 final ST self = scope.st;
1234 STGroup g = self.impl.nativeGroup;
1235 Object o = getDictionary(g, name);
1236 if ( o !=null ) return o;
1237
1238 // not found, report unknown attr
1239 throw new STNoSuchAttributeException(name, scope);
1240 }
1241
1242 public Object getDictionary(STGroup g, String name) {
1243 if ( g.isDictionary(name) ) {

Callers 2

_execMethod · 0.95
passthruMethod · 0.95

Calls 2

getDictionaryMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected