01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.pack200.bytecode;
18:
19: import java.io.DataOutputStream;
20: import java.io.IOException;
21:
22: public class LineNumberTableAttribute extends BCIRenumberedAttribute {
23:
24: private int line_number_table_length;
25: private int[] start_pcs;
26: private int[] line_numbers;
27:
28: public LineNumberTableAttribute(int line_number_table_length,
29: int[] start_pcs, int[] line_numbers) {
30: super ("LineNumberTable");
31: this .line_number_table_length = line_number_table_length;
32: this .start_pcs = start_pcs;
33: this .line_numbers = line_numbers;
34: }
35:
36: protected int getLength() {
37: return 2 + (4 * line_number_table_length);
38: }
39:
40: protected void writeBody(DataOutputStream dos) throws IOException {
41: dos.writeShort(line_number_table_length);
42: for (int i = 0; i < line_number_table_length; i++) {
43: dos.writeShort(start_pcs[i]);
44: dos.writeShort(line_numbers[i]);
45: }
46: }
47:
48: /* (non-Javadoc)
49: * @see org.apache.harmony.pack200.bytecode.ClassFileEntry#toString()
50: */
51: public String toString() {
52: return "LineNumberTable: " + line_number_table_length
53: + " lines";
54: }
55:
56: /* (non-Javadoc)
57: * @see org.apache.harmony.pack200.bytecode.Attribute#getNestedClassFileEntries()
58: */
59: protected ClassFileEntry[] getNestedClassFileEntries() {
60: return new ClassFileEntry[] { getAttributeName() };
61: }
62:
63: /* (non-Javadoc)
64: * @see org.apache.harmony.pack200.bytecode.Attribute#resolve(org.apache.harmony.pack200.bytecode.ClassConstantPool)
65: */
66: protected void resolve(ClassConstantPool pool) {
67: super .resolve(pool);
68: }
69:
70: protected int[] getStartPCs() {
71: return start_pcs;
72: }
73: }
|