Artifact d365fb9e8ae285b0e77afd5d1d1f9ea857229cd783eb86b0c9b63d3d5ceb1ee9:
- Executable file
r37/lisp/csl/jlisp/Code_attribute.java
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2771) [annotate] [blame] [check-ins using] [more...]
import java.io.*; public class Code_attribute extends Attribute_info { short max_stack; short max_locals; int code_length = 0; byte[] code = new byte[0]; short exception_table_length = 0; /* IGNORE EXCEPTIONS short start_pc; // shall I introduce a new type for this? short end_pc; // no exceptions for any of Trivial.java short handler_pc; short catch_type; exception_table[]; //should be [exception_table_length] */ short attributes_count = (short)0; byte attributes[]; //should be Attribute_info attributes[attributes_count] //but ignoring LineNumberTable here void setStackLocals(short stack, short locals) { max_stack = stack; max_locals = locals; } /* void addInstruction(byte instr) { byte[] codeTemp = new byte[code.length+1]; for (int i=0; i<code.length; i++) codeTemp[i] = code[i]; codeTemp[code.length] = instr; code_length++; code = new byte[codeTemp.length]; code = codeTemp; } */ void addInstruction(byte instr, byte args[]) { byte[] codeTemp = new byte[code.length+args.length+1]; for (int i=0; i<code.length; i++) codeTemp[i] = code[i]; // copy code to codeTemp codeTemp[code.length] = instr; // add instruction code_length++; for (int i=0; i<args.length; i++) { codeTemp[i+code.length+1] = args[i]; code_length++; } code = new byte[codeTemp.length]; code = codeTemp; } void addInstruction(byte instr) //no args { byte[] emptyarray = new byte[] {}; addInstruction(instr, emptyarray); } void addInstruction(byte instr, byte b) //byte arg { addInstruction(instr, ByteArray.byteToByteArray(b)); } void addInstruction(byte instr, short s) //short arg { addInstruction(instr, ByteArray.shortToByteArray(s)); } void toInfo() throws IOException { byte[][] infoTemp = new byte[7][0]; infoTemp[0] = ByteArray.shortToByteArray(max_stack); infoTemp[1] = ByteArray.shortToByteArray(max_locals); infoTemp[2] = ByteArray.intToByteArray(code_length); infoTemp[3] = code; infoTemp[4] = ByteArray.shortToByteArray(exception_table_length); infoTemp[5] = ByteArray.shortToByteArray(attributes_count); if (attributes_count == 0) {} else infoTemp[6] = attributes; info = ByteArray.flatBytes(infoTemp); attribute_length = info.length; } } // end of Code_attribute.java