jpl0cproject的所有源文件.docx
《jpl0cproject的所有源文件.docx》由会员分享,可在线阅读,更多相关《jpl0cproject的所有源文件.docx(151页珍藏版)》请在课桌文档上搜索。
1、* Code.java*Createdon2005Ae2A22E0zEltl0z33*1.astmodify:2005-2-27.*Author:WAngNan(BHU32060601)* Thisprogramisfreesoftware;youcanredistributeitand/ormodify* itunderthetermsoftheGNUGeneralPublic1.icenseaspublishedby* theFreeSoftwareFoundation;eitherversion2ofthe1.icense,or* (atyouroption)anylaterversio
2、n.packageattributesincompile;importInstructionsused.*;importjava.util.*;/* 0authorwn*/Code1.ength=0;maxstack=1;currentstack=1;/ifmysolutioniswrong,thispublicclassCodepublicintpublicintpublicint1mayletitgo.newpublicVectorInstructions1.istVector();publicvoidappend(InstructionOP)Instructions1.ist.add(O
3、P);Code1.ength+=OP.get1.ength();currentstack+=OP.getStackUsed();if(currentstackmaxstack)maxstack=currentstack;)publicvoidappendAll(Codefrag)for(inti=0;ifrag.Instructions1.ist.size();i+)append(frag.Instructions1.ist.get(i);)*for(Instructioni:frag.Instructions1.ist)append(i);)*/*CreatesanewinstanceofC
4、ode*/publicCode()* Var1.ist.java*Createdon2005Ae2A21EzIAtl247*1.astmodify:2005-2-21.*Author:WAngNan(BHU32060601)* Thisprogramisfreesoftware;youcanredistributeitand/ormodify* itunderthetermsoftheGNUGeneralPublic1.icenseaspublishedby* theFreeSoftwareFoundation;eitherversion2ofthe1.icense,or* (atyourop
5、tion)anylaterversion.packageattributesincompile;importjava.util.*;importglobal.*;*authorwn*/publicclassVar1.istWithTypepublicVectorVarsName=newVector();publicTAB1.E_NODE_TYPESVarsType=null;publicbooleanisArray=false;*CreatesanewinstanceofVar1.ist*/publicVar1.istWithType()(CreateClassFile.javaCreated
6、on2005Ae20A24EzIAt2rO81.astmodify:2005-3-2.*Author:WAngNan(BHU32060601)* Thisprogramisfreesoftware;youcanredistributeitand/ormodify* itunderthetermsoftheGNUGeneralPublic1.icenseaspublishedby* theFreeSoftwareFoundation;eitherversion2ofthe1.icense,or* (atyouroption)anylaterversion.packagedumpper;impor
7、ttables.*;importglobal.*;importtables.*;importattributesincompile.*;importinstructionsused.*;importjava.io.;importjava.util.*;* authorwn* /publicclassCreateClassFilepublicvoidWriteHeader()throwsIOExceptionOut.writelnt(OxCAFEBABE);/magicOut.WriteShort(O);/minor_versionOut.WriteShort(49);/major_versio
8、n)publicvoidCountconstantPoolNum()CompileTimeCPCTCP=newCompileTimeCP();for(CompileTimeCPNodeNode:CTCP.Pool)if(Node.Type=CONSTANT_POO1._NODE_TYPE.STRING)ConstantPoolNum+=2;elseConstantPoolNum+=1;)for(ObjectNode:Table.dump()if(GlobalTableNode)(Node).KindTAB1.E_NODE_KINDS.CONSTANT)if(GlobalTableNode)No
9、de).KindTAB1.E_NODE_KINDS.FUNCTION)ConstantPoolNum+=4;elseConstantPoolNum+=3;publicvoidWriteMethodref(intC1.ASS,intNameAndType)throwsIOExceptionOut.writeByte(10);Out.writeShort(C1.ASS);Out.writeShort(NameAndType);publicvoidWriteFieldref(intC1.ASS,intNameAndType)throwsIOExceptionOut.writeByte(9);Out.
10、writeShort(C1.ASS);Out.writeShort(NameAndType);publicvoidWriteClass(intName)throwsIOExceptionOut.writeByte(7);Out.writeShort(Name);publicvoidWriteNameAndType(intName,intType)throwsIOExceptionOut.WriteByte(12);Out.writeShort(Name);Out.writeShort(Type);)publicvoidwriteUTF8(StringS)throwsIOExceptionfOu
11、t.WriteByte(1);Out.WriteShort(S.length();Out.writeBytes(三);publicvoidWriteConstantString(intIndex)throwsIOExceptionOut.writeByte(8);Out.WriteShort(Index);)publicvoidWriteConstantInt(intBytes)throwsIOExceptionOut.writeByte(3);Out.writelnt(Bytes);)publicvoidWriteConstantFloat(floatBytes)throwsIOExcept
12、ionOut.writeByte(4);Out.writeFloat(Bytes);)publicvoidWriteStartOfCP()throwsIOException9);/l10);/2ll);/312);/413);/514);/6WriteMethodref(8,WriteMethodref(7,WriteMethodref(7,WriteMethodref(7,WriteMethodref(7,WriteMethodref(7,WriteClass(40);/7WriteClass(39);/8WriteNameAndType(15,16);/9WriteNameAndType(
13、17,18);/10WriteNameAndType(19,20);/11WriteNameAndType(21,22);/12WriteNameAndType(23,24);/13WriteNameAndType(25,26);/14writeUTF8(,);/15writeUTF8(,()Vn);/16writeUTF8(nWRITEINTn);/17writeUTF8(n(I)V11);/18writeUTF8(nWRITECHARu);/19writeUTF8(C)V11);/20writeUTF8(nWRITEBOO1.EANn);/21writeUTF8(11(Z)V11);/22
14、writeUTF8(nWRITESTRINGn);/23writeUTF8(,(1.java/lang/String;)Vn);/24writeUTF8(nWRITEF1.OATn);/25writeUTF8(,(F)V);/26writeUTF8(main*);/27writeUTF8(,(1.java/lang/String;V11);/28writeUTF8(,I11);/29writeUTF8(F11);/30writeUTF8(,Z11);/31writeUTF8(,C,)32writeUTF8(,javalangString11);/33writeUTF8(,I,);/34writ
15、eUTF8(nFn);/35writeUTF8(nZn);/36writeUTF8(,C);/37writeUTF8(nCoden);/38writeUTF8(,jplOlangProgram,);/39writeUTF8(Table.ProgName);/40*Out.writeShort(0x0021);/ACCESSF1.AGOut.writeShort(7);/ThisClassOut.writeShort(8);/Superclass;Out.WriteShort(O);/InterfaceCount;*/publicvoidWriteConstTable()throwsIOExce
16、ptionCompileTimeCPCTCP=newCompileTimeCP();for(CompileTimeCPNodeNode:CTCP.Pool)ConstantPoolIndex+;if(Node.Type=CONSTANT_POO1._NODE_TYPE.STRING)writeUTF8(Node.getStringVlue();ConstantPoolIndex+;WriteConstantString(ConstantPoolIndex-1);Node.Index=ConstantPoolIndex;elseNode.Index=ConstantPoolIndex;if(No
17、de.Type=CONSTANT_POO1._NODE_TYPE.F1.OAT)WriteConstantFloat(Node.getFloatValue();elseWriteConstantInt(Node.getlntValue();)publicvoidWriteGlobalTable()throwsIOExceptionfintNameindex,NameAndTypeIndex,Index;for(ObjectNode:Table.dump()GlobalTableNodeCNode=(GlobalTableNode)(Node);if(CNode.Kind!=TAB1.E_NOD
18、E_KINDS.CONSTANT)ConstantPoolIndex+;if(CNode.Kind=TAB1.E_NODE_KINDS.FUNCTION)writeUTF8(FunctionNode)(CNode).OrgiName);(FunctionNode)(CNode).name_index=ConstantPoolIndex;ConstantPoolIndex+;writeUTF8(FunctionNode)(CNode).FullDescirptor);(FunctionNode)(CNode).descriptor_index=ConstantPoolIndex;Constant
19、PoolIndex+;WriteNameAndType(ConstantPoolIndex-2,ConstantPoolIndex-I);ConstantPoolIndex+;WriteMethodref(7,ConstantPoolIndex-I);(FunctionNode)(CNode).method_ref_index=ConstantPoolIndex;(FunctionNode)(CNode).IndexInCP=ConstantPoolIndex;Methods.add(CNode);elseinttype;switch(CNode.Type)caseCHAR:type=37;b
20、reak;caseBOO1.EAN:type=36;break;caseF1.OAT:type=35;break;caseINTEGER:type=34;break;default:type=33;)if(CNode.Kind=TAB1.E_NODE_KINDS.ARRAY)type=type-5;/ConstantPoolIndex+;writeUTF8(CNOde.getName();(GlobalVarNode)CNode).name_index=ConstantPoolIndex;ConstantPoolIndex+;WriteNameAndType(ConstantPoolIndex
21、-Iztype);(GlobalVarNode)CNode).descriptor_index=type;ConstantPoolIndex+;WriteFieldref(7,ConstantPoolIndex-I);CNode.IndexInCP=ConstantPoolIndex;FieldsCount+;Fields.add(CNode);)GlobalTableTable;DataOutputStreamOut;intConstantPoolNum=40;intConstantPoolIndex=40;intFieldsCount=O;VectorFields=newVector();
22、VectorMethods=newVector();*CreatesanewinstanceofCreateClassFile*/publicCreateClassFile(GlobalTableTable)throwsIOExceptionthis.Table=Table;try(Out=newDataOutputStream(newFileOutputStream(Table.ProgName+,.class1);WriteHeader();CountconstantPoolNuin();/Out.writeShort(ConstantPoolNum);Out.WriteShort(Con
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- jpl0cproject 所有 源文件

链接地址:https://www.desk33.com/p-1415509.html