本文整理汇总了Golang中github.com/zxh0/jvm/go/jvmgo/jvm/rtda/class.Method类的典型用法代码示例。如果您正苦于以下问题:Golang Method类的具体用法?Golang Method怎么用?Golang Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Method类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewFrame
func (self *Thread) NewFrame(method *rtc.Method) *Frame {
if method.IsNative() {
return newNativeFrame(self, method)
} else {
return self.frameCache.borrowFrame(method)
//return newFrame(self, method)
}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:8,代码来源:thread.go
示例2: InvokeMethod
func (self *Thread) InvokeMethod(method *rtc.Method) {
//self._logInvoke(self.stack.size, method)
currentFrame := self.CurrentFrame()
newFrame := self.NewFrame(method)
self.PushFrame(newFrame)
argSlotsCount := method.ArgSlotCount()
if argSlotsCount > 0 {
_passArgs(currentFrame.operandStack, newFrame.localVars, argSlotsCount)
}
if method.IsSynchronized() {
var monitor *rtc.Monitor
if method.IsStatic() {
classObj := method.Class().JClass()
monitor = classObj.Monitor()
} else {
thisObj := newFrame.LocalVars().GetThis()
monitor = thisObj.Monitor()
}
monitor.Enter(self)
newFrame.SetOnPopAction(func() {
monitor.Exit(self)
})
}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:26,代码来源:thread.go
示例3: borrowFrame
func (self *FrameCache) borrowFrame(method *rtc.Method) *Frame {
if self.frameCount > 0 {
for i, frame := range self.cachedFrames {
if frame != nil &&
frame.maxLocals >= method.MaxLocals() &&
frame.maxStack >= method.MaxStack() {
self.frameCount--
self.cachedFrames[i] = nil
frame.reset(method)
return frame
}
}
}
return newFrame(self.thread, method)
}
开发者ID:cretz,项目名称:jvm.go,代码行数:16,代码来源:frame_cache.go
示例4: getParameterTypeArr
func getParameterTypeArr(method *rtc.Method) *rtc.Obj {
paramTypes := method.ParameterTypes()
paramCount := len(paramTypes)
classClass := rtc.BootLoader().JLClassClass()
classArr := classClass.NewArray(uint(paramCount))
if paramCount > 0 {
classObjs := classArr.Refs()
for i, paramType := range paramTypes {
classObjs[i] = paramType.JClass()
}
}
return classArr
}
开发者ID:cretz,项目名称:jvm.go,代码行数:16,代码来源:Class_helper.go
示例5: getExceptionTypeArr
func getExceptionTypeArr(method *rtc.Method) *rtc.Obj {
exTypes := method.ExceptionTypes()
exCount := len(exTypes)
classClass := rtc.BootLoader().JLClassClass()
classArr := classClass.NewArray(uint(exCount))
if exCount > 0 {
classObjs := classArr.Refs()
for i, exType := range exTypes {
classObjs[i] = exType.JClass()
}
}
return classArr
}
开发者ID:cretz,项目名称:jvm.go,代码行数:16,代码来源:Class_helper.go
示例6: newFrame
func newFrame(thread *Thread, method *rtc.Method) *Frame {
return &Frame{
thread: thread,
method: method,
maxLocals: method.MaxLocals(),
maxStack: method.MaxStack(),
localVars: newLocalVars(method.MaxLocals()),
operandStack: newOperandStack(method.MaxStack()),
}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:10,代码来源:frame.go
示例7: newNativeFrame
func newNativeFrame(thread *Thread, method *rtc.Method) *Frame {
frame := &Frame{}
frame.thread = thread
frame.method = method
frame.localVars = newLocalVars(method.ArgSlotCount()) // todo
frame.operandStack = newOperandStack(4) // todo
code := method.Code()
if code == nil {
code = getHackCode(method.Descriptor())
method.HackSetCode(code)
}
return frame
}
开发者ID:cretz,项目名称:jvm.go,代码行数:15,代码来源:native_frame.go
示例8: _logInvoke
func (self *Thread) _logInvoke(stackSize uint, method *rtc.Method) {
space := strings.Repeat(" ", int(stackSize))
className := method.Class().Name()
methodName := method.Name()
if method.IsStatic() {
fmt.Printf("[method]%v thread:%p %v.%v()\n", space, self, className, methodName)
} else {
fmt.Printf("[method]%v thread:%p %v#%v()\n", space, self, className, methodName)
}
}
开发者ID:cretz,项目名称:jvm.go,代码行数:11,代码来源:thread.go
示例9: getReturnType
func getReturnType(method *rtc.Method) *rtc.Obj {
goReturnType := method.ReturnType()
return goReturnType.JClass()
}
开发者ID:cretz,项目名称:jvm.go,代码行数:4,代码来源:Class_helper.go
示例10: convertArgs
// Object[] -> []Any
func convertArgs(this, argArr *rtc.Obj, method *rtc.Method) []Any {
if method.ArgSlotCount() == 0 {
return nil
}
if method.ArgSlotCount() == 1 && !method.IsStatic() {
return []Any{this}
}
argObjs := argArr.Refs()
argTypes := method.ParsedDescriptor().ParameterTypes()
args := make([]Any, method.ArgSlotCount())
j := 0
if !method.IsStatic() {
args[0] = this
j = 1
}
for i, argType := range argTypes {
argObj := argObjs[i]
if argType.IsBaseType() {
// todo
unboxed := box.Unbox(argObj, argType.Descriptor())
args[i+j] = unboxed
if argType.IsLongOrDouble() {
j++
}
} else {
args[i+j] = argObj
}
}
return args
}
开发者ID:cretz,项目名称:jvm.go,代码行数:36,代码来源:helper.go
注:本文中的github.com/zxh0/jvm/go/jvmgo/jvm/rtda/class.Method类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论