Skip to content

Commit

Permalink
Implement InvokeInterface
Browse files Browse the repository at this point in the history
Conflicts:

	src/main/scala/cafebabe/AbstractByteCode.scala
  • Loading branch information
pradeepk authored and psuter committed Apr 5, 2012
1 parent 81baed3 commit 3678d6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/scala/cafebabe/AbstractByteCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,13 @@ object AbstractByteCodes {
ch.constantPool.addString(fieldName),
ch.constantPool.addString(fieldType))))
}

// Method invocations

// Not implemented yet. We should generate the two extra bytes properly ("count" and 0).
/* object InvokeInterface {

object InvokeInterface {
def apply(className: String, methodName: String, methodSig: String): AbstractByteCodeGenerator =
invokeMethod(INVOKEINTERFACE, className, methodName, methodSig)
} */

_ << invokeMethod(INVOKEINTERFACE, className, methodName, methodSig) <<
RawByte(methodSignatureArgStackEffect(methodSig) + 1) << RawByte(0)
}

object InvokeSpecial {
def apply(className: String, methodName: String, methodSig: String): AbstractByteCodeGenerator =
invokeMethod(INVOKESPECIAL, className, methodName, methodSig)
Expand Down
5 changes: 5 additions & 0 deletions src/main/scala/cafebabe/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ package object cafebabe {
case MethSigRE(args,ret) => typeToByteCount(ret) - typesToByteCount(args)
case _ => sys.error("Malformed method signature: " + sig)
}
private[cafebabe] def methodSignatureArgStackEffect(sig: String) : Int = sig match {
case MethSigRE(args,ret) =>
typesToByteCount(args) // does not account for 'this' since we don't know if this is static
case _ => sys.error("Malformed method signature: " + sig)
}

// the meat of the parser
private def parseRec(s : String) : (Int,String,String) = if(s.isEmpty) (0,s,s) else {
Expand Down

0 comments on commit 3678d6b

Please sign in to comment.