| Class | Ruva::VM::Class::Reader::UnresolvedMember |
| In: |
lib/ruva/class_loader.rb
|
| Parent: | Object |
Just a base-class for classes and members that gives some handy helpers for working with attributes.
| access | [RW] | |
| attrs | [RW] | |
| clz | [RW] |
# File lib/ruva/class_loader.rb, line 157
157: def initialize(clz, access = 0, attrs = [])
158: @clz, @access, @attrs = clz, access, attrs
159: end
# File lib/ruva/class_loader.rb, line 247
247: def do_visit_annotations(visitor)
248: annotations.each do |a|
249: case a.name
250: when /Invisible/
251: if a.name =~ /Parameter/
252: av = visitor.visit_parameter_annotation(a.data[:parameter_idx], a.data[:descriptor], false)
253: else
254: av = visitor.visit_annotation(a.data[:descriptor], false)
255: end
256:
257: # TODO visit the bits
258:
259: av.visit_end
260: when /Visible/
261: if a.name =~ /Parameter/
262: av = visitor.visit_parameter_annotation(a.data[:parameter_idx], a.data[:descriptor], true)
263: else
264: av = visitor.visit_annotation(a.data[:descriptor], true)
265: end
266:
267:
268: # TODO visit the bits
269:
270: av.visit_end
271: when /Default/
272: av = visitor.visit_annotation_default
273:
274: # TODO visit the bits
275:
276: av.visit_end
277: else
278: raise VMError, "Unknown annotation type #{a.name} on #{self.inspect}"
279: end
280: end
281: end
Generic, works with all types of visitor as long as class is valid
# File lib/ruva/class_loader.rb, line 215
215: def do_visit_std_attrs(visitor)
216: std_attrs.each do |a|
217: case a.name
218: when 'SourceFile'
219: # TODO passing 'debug' incorrectly?
220: visitor.visit_source(a.data.data, nil)
221: when 'ConstantValue'
222: # do nothing, handled manually
223: when 'Code'
224: # handled in method visit
225: #visitor.visit_maxs(a.data[:max_locals], a.data[:max_stack])
226: #visitor.visit_code(a.data[:code])
227: when 'Exceptions'
228: # do nothing, this is done during the method visit
229: when 'InnerClasses'
230: # do nothing, handled during class visit
231: when 'Synthetic'
232: # TODO unsupported
233: when 'LineNumberTable'
234: a.data.each { |ln| visitor.visit_line_number(ln[:line_number], ln[:start_pc])}
235: when 'LocalVariableTable'
236: # Do nothing, handled manually
237: when 'LocalVariableTypeTable'
238: # Do nothing, handled manually
239: when 'Signature'
240: # Do nothing, handled manually
241: when 'Deprecated'
242: # TODO unsupported, not required by vm
243: end
244: end
245: end
returns [std_attrs, annotations, other_attrs]
# File lib/ruva/class_loader.rb, line 183
183: def split_attrs
184: std_attrs = attrs.select { |a| a.name =~ /^(SourceFile |
185: ConstantValue |
186: Code |
187: Exceptions |
188: InnerClasses |
189: Synthetic |
190: LineNumberTable |
191: LocalVariableTable |
192: LocalVariableTypeTable |
193: Signature |
194: RuntimeVisibleAnnotations |
195: RuntimeInvisibleAnnotations |
196: RuntimeVisibleParameterAnnotations |
197: RuntimeInvisibleParameterAnnotations |
198: AnnotationDefault |
199: Deprecated)$/x }
200:
201: other_attrs = attrs - std_attrs
202:
203: annotations, std_attrs = std_attrs.partition do |a|
204: a.name =~ /RuntimeVisibleAnnotations |
205: RuntimeInvisibleAnnotations |
206: RuntimeVisibleParameterAnnotations |
207: RuntimeInvisibleParameterAnnotations |
208: AnnotationDefault/x
209: end
210:
211: [std_attrs, annotations, other_attrs]
212: end