MCPcopy Index your code
hub / github.com/beanshell/beanshell / getType

Method getType

src/bsh/BSHType.java:134–168  ·  view source on GitHub ↗
( CallStack callstack, Interpreter interpreter )

Source from the content-addressed store, hash-verified

132 }
133
134 public Class getType( CallStack callstack, Interpreter interpreter )
135 throws EvalError
136 {
137 // return cached type if available
138 if ( type != null )
139 return type;
140
141 // first node will either be PrimitiveType or AmbiguousName
142 SimpleNode node = getTypeNode();
143 if ( node instanceof BSHPrimitiveType )
144 baseType = ((BSHPrimitiveType)node).getType();
145 else
146 baseType = ((BSHAmbiguousName)node).toClass(
147 callstack, interpreter );
148
149 if ( arrayDims > 0 ) {
150 try {
151 // Get the type by constructing a prototype array with
152 // arbitrary (zero) length in each dimension.
153 int[] dims = new int[arrayDims]; // int array default zeros
154 Object obj = Array.newInstance(baseType, dims);
155 type = obj.getClass();
156 } catch(Exception e) {
157 throw new EvalError("Couldn't construct array type",
158 this, callstack );
159 }
160 } else
161 type = baseType;
162
163 // hack... sticking to first interpreter that resolves this
164 // see comments on type instance variable
165 interpreter.getClassManager().addListener(this);
166
167 return type;
168 }
169
170 /**
171 baseType is used during evaluation of full type and retained for the

Callers 2

evalTypeMethod · 0.95
evalMethod · 0.95

Calls 5

getTypeNodeMethod · 0.95
getClassMethod · 0.80
toClassMethod · 0.45
addListenerMethod · 0.45
getClassManagerMethod · 0.45

Tested by

no test coverage detected