B::JVM::Jasmin::Emit

B::JVM::Jasmin::Emit is a package used by B::JVM::Jasmin to emit Jasmin syntaxed file.
Download

B::JVM::Jasmin::Emit Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Bradley M. Kuhn
  • Publisher web site:
  • http://search.cpan.org/~bkuhn/B-JVM-Jasmin-0.02/lib/B/JVM/Utils.pm

B::JVM::Jasmin::Emit Tags


B::JVM::Jasmin::Emit Description

B::JVM::Jasmin::Emit is a package used by B::JVM::Jasmin to emit Jasmin syntaxed file. B::JVM::Jasmin::Emit is a package used by B::JVM::Jasmin to emit Jasmin syntaxed file.SYNOPSIS use B::JVM::Jasmin::Emit; my $emitter = new B::JVM::Emit(FILEHANDLE); # ... $emitter->DIRECTIVE_NAME(); # ... $emitter->OPCODE_NAME(); # ... $emitter->OPCODE_NAME();This class is used emit JVM assembler code in Jasmin syntax. Each method one can use is either an opcode or a directive supported by Jasmin syntax.B::JVM::Jasmin::Emit Package Variables$VERSIONVersion number of B::JVM::Jasmin::Emit. For now, it should always match the version of B::JVM::Jasmin@EXPORT_OKAll the methods that one can grab from B::JVM::Jasmin::Emit@EXPORTWe don't export anything by default.Modules used by B::JVM::Jasmin::EmitCarpUsed for error reportingB::JVM::UtilsUsed to get needed utility functions, such as ExtractMethodData and IsValidMethodStringMethods in B::JVM::Jasmin::EmitB::JVM::Jasmin::Emit::newusage: B::JVM::Emit::new(FILEHANDLE, )Creates a new object of the class. It assumes that FILEHANDLE is a lexically scoped file handle open for writing, and that SOURCE_FILE_NAME that should be used for a source directive. SOURCE_FILE_NAME is optional, but may annoys someone firing up your code in the Java debugger.B::JVM::Emit::Jasmin::_clearMethodData()usage: $jasminEmitter->_clearMethodData()Clear out the method data elements of the Jasmin emitterB::JVM::Emit::Jasmin::sourceusage: B::JVM::Emit::Jasmin::source(SOURCE_FILE_NAME)Emits the source file name directive.B::JVM::Emit::Jasmin::commentusage: B::JVM::Emit::Jasmin::comment($methodName, $commentString)Puts $commentString in a comment in the file, in the code for method $metohdName.B::JVM::Emit::Jasmin::superusage: B::JVM::Emit::Jasmin::super(CLASS_NAME)sends class directive, using CLASS_NAME, to the output fileB::JVM::Emit::Jasmin::classusage: B::JVM::Emit::Jasmin::class(ACCESS_SPEC, CLASS_NAME)sends class directive, using CLASS_NAME to the ACCESS_SPEC, to the output fileB::JVM::Emit::Jasmin::interfaceusage: B::JVM::Emit::Jasmin::interface(ACCESS_SPEC, INTERFACE_NAME)sends interface directive, using INTERFACE_NAME to the ACCESS_SPEC, to the output fileB::JVM::Emit::Jasmin::implementsusage: B::JVM::Emit::Jasmin::implements(CLASS_NAME)sends implements directive, using CLASS_NAME to the output fileB::JVM::Emit::Jasmin::labelCreateusage: $emitter-labelCreate($methodName, $labelNameRequested)>In method, $methodName, creates a new label, whose name will "resemble" $labelNameRequested. This label is not actually sent to the output, that must be done later with $emitter-labelSend($methodName, $value)>.Note that the value returned from this method is the actual label name assigned and will only "resemble" (i.e., not match exactly) the $labelNameRequested.B::JVM::Emit::Jasmin::labelSendusage: $emitter-labelSend($methodName, $labelName)>Send a label, $labelName, to the output of method, $methodName.This label must be valid label previously returned from $emitter-labelCreate($methodName, $someValue)>.B::JVM::Emit::Jasmin::fieldusage: B::JVM::Emit::Jasmin::field(ACCESS_SPEC, FIELD_NAME, TYPE, )sends field directive, using the arguments given, to the output fileB::JVM::Emit::Jasmin::methodStartusage: $emitter->methodStart(METHOD_NAME, ACCESS_SPEC, )sends method directive and other directives needed to start up a new method. Also sets the current method for the emitter. STACK_SIZE is optional. However, a stack size is always set to a default value (currently 256), because if it is not set, a number of problems occur with the stack.B::JVM::Emit::Jasmin::methodCreateLocalusage: $emitter->methodCreateLocal(METHOD_NAME, VARIABLE_NAME_REQUEST, VARIABLE_TYPE, , )Creates a local of type VARIABLE_TYPE, with a given name in method, METHOD_NAME. If LABEL1 is given, LABEL2 must be given, and vice versa.If the labels are given, then the variable is only valid between those two labels in the resulting assembler source.methodCreateLocal attempts to give a variable name that "resembles" VARIABLE_NAME_REQUEST. If the labels are given, it is guaranteed that the variable name will "resemble" the VARIABLE_NAME_REQUEST.If the labels are not given, it is very likely that an old local variable of the same type will be returned.The actual variable name given will be returned. It is imperative that the user of methodCreateLocal use this variable name, and not VARIABLE_NAME_REQUEST, for obvious reasons.B::JVM::Emit::Jasmin::methodFreeLocalusage: $emitter->methodFreeLocal(METHOD_NAME VARIABLE_NAME)Indicates that the local, VARIABLE_NAME, in method, METHOD_NAME, is no longer in use. It is not required that locals be freed in this manner, however, many, many locals can be allocated unnecessarily if this is not done.B::JVM::Emit::Jasmin::methodEndusage: $emitter-methodEnd($method, )>Finishes up a method, $method, that is currently being emitted. If $debug is defined and is true, then ".line" directives will be put into the output for debugging purposes.B::JVM::Emit::Jasmin::astoreusage: $emitter->astore()Emits an "astore" instruction, using the VARIABLE name in METHOD given, if one is given. If VARIABLE is given, it is looked up in variables created with B::JVM::Emit::Jasmin::methodCreateLocal() for the given method, METHOD.B::JVM::Emit::Jasmin::invokevirtualusage: $emitter->invokevirtual(METHOD_IN, METHOD_INVOKED)Emits an "invokevirtual" instruction to invoke METHOD_INVOKED in the code for METHOD_INB::JVM::Emit::Jasmin::ifneusage: $emitter-ifne($methodName, $labelName)>Emits an "ifne" instruction with argument, $labelName in the code for method, $methodName.This label, $labelName must be valid label previously returned from $emitter-labelCreate($methodName, $someValue)>.B::JVM::Emit::Jasmin::ifequsage: $emitter-ifeq($methodName, $labelName)>Emits an "ifeq" instruction with argument, $labelName in the code for method, $methodName.This label, $labelName must be valid label previously returned from $emitter-labelCreate($methodName, $someValue)>.B::JVM::Emit::Jasmin::aloadusage: $emitter->aload()Emits an "aload" instruction, using the VARIABLE name in METHOD given, if one is given. If VARIABLE is given, it is looked up in variables created with B::JVM::Emit::Jasmin::methodCreateLocal() for the given method, METHOD.B::JVM::Emit::Jasmin::invokestaticusage: $emitter->invokevirtual(METHOD_IN, METHOD_INVOKED)Emits an "invokestatic" instruction to invoke METHOD_INVOKED in the code for METHOD_INB::JVM::Emit::Jasmin::iconstusage: $emitter->iconst(METHOD, VALUE)Emits an "iconst" instruction, using the value of VALUE for the constant, in the method named METHOD.B::JVM::Emit::Jasmin::istoreusage: $emitter->istore()Emits an "istore" instruction, using the VARIABLE name in METHOD given, if one is given. If VARIABLE is given, it is looked up in variables created with B::JVM::Emit::Jasmin::methodCreateLocal() for the given method, METHOD.B::JVM::Emit::Jasmin::iloadusage: $emitter->iload()Emits an "iload" instruction, using the VARIABLE name in METHOD given, if one is given. If VARIABLE is given, it is looked up in variables created with B::JVM::Emit::Jasmin::methodCreateLocal() for the given method, METHOD.B::JVM::Emit::Jasmin::iandusage: $emitter->iand()Emits an "iand" instruction, in METHOD given, if one is given.B::JVM::Emit::Jasmin::popusage: $emitter->pop()Emits an "pop" instruction, in METHOD given, if one is given.B::JVM::Emit::Jasmin::getstaticusage: $emitter->getstatic(METHOD_IN, FIELD, TYPE)Emits an "getstatic" instruction for the field, FIELD, of type, TYPE in the code for METHOD_INB::JVM::Emit::Jasmin::ldcusage: $emitter->ldc(METHOD_IN, VALUE)Emits an "ldc" instruction with the value of VALUE, in the method METHOD_IN.B::JVM::Emit::Jasmin::newObjectusage: $emitter->newObject(METHOD_IN, CLASS)Emits an "new" instruction for the class, CLASS in the body for the method, METHOD_IN. CLASS must be a valid class name.B::JVM::Emit::Jasmin::invokespecialusage: $emitter->invokespecial(METHOD_IN, METHOD_INVOKED)Emits an "invokespecial" instruction to invoke METHOD_INVOKED in the code for METHOD_INB::JVM::Emit::Jasmin::dupusage: $emitter-dup($method)>Emits an "dup" instruction in the code for the method, $methodB::JVM::Emit::Jasmin::swapusage: $emitter-swap($method)>Emits an "swap" instruction in the code for the method, $methodB::JVM::Emit::Jasmin::gotoLabelusage: $emitter-gotoLabel($methodName, $labelName)>Emits an "goto" instruction with argument, $labelName in the code for method, $methodName.This label, $labelName must be valid label previously returned from $emitter-labelCreate($methodName, $someValue)>.B::JVM::Emit::Jasmin::returnVoidusage: $emitter->returnVoid(METHOD_IN)Emits an "return" instruction in the code for method, METHOD_IN.B::JVM::Emit::Jasmin::iincusage: $emitter-iinc($method, $variable, $amount)>Emits an "iinc" instruction, using the $variable name in the method, $method. The variable, $variable must have one previously returned from methodCreateLocal($method, ...) that has not been freed with methodFreeLocal($method, ...) yet.$amount is the integer amount to increment $variable by.B::JVM::Emit::Jasmin::bipushusage: $emitter-bipush($method, $value)>Emits an "bipush" instruction, into the method, $method using the value of $value. Note that an "iconst" or an "iconst_m1" instruction is emitted if the $value is the range where "iconst" will work.B::JVM::Emit::Jasmin::aastoreusage: $emitter-aastore($method)>Emits an "aastore" instruction, into the method, $method.B::JVM::Emit::Jasmin::isubusage: $emitter-isub($method)>Emits an "isub" instruction, into the method, $method.B::JVM::Emit::Jasmin::nopusage: $emitter-nop($method)>Emits a "nop" instruction, into the method, $method.B::JVM::Emit::Jasmin::aaloadusage: $emitter-aaload($method)>Emits an "aaload" instruction, into the method, $method.B::JVM::Emit::Jasmin::anewarrayusage: $emitter-anewarray($method, $type)>Emits an "anewarray" instruction, into the method, $method. The new array will be of type $type. The method will fail if $type is not a valid JVM type identifier. Requirements: · Perl


B::JVM::Jasmin::Emit Related Software