text
stringlengths
9
39.2M
dir
stringlengths
25
226
lang
stringclasses
163 values
created_date
timestamp[s]
updated_date
timestamp[s]
repo_name
stringclasses
751 values
repo_full_name
stringclasses
752 values
star
int64
1.01k
183k
len_tokens
int64
1
18.5M
```javascript // Thanks to path_to_url class TributeSearch { constructor(tribute) { this.tribute = tribute this.tribute.search = this } simpleFilter(pattern, array) { return array.filter(string => { return this.test(pattern, string) }) } test(pattern, st...
/content/code_sandbox/src/TributeSearch.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
899
```javascript /*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license //@ sourceMappingURL=jquery-1.10.2.min.map */ (function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.ha...
/content/code_sandbox/test/libs/jquery-1.10.2.min.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
31,238
```javascript // Thanks to path_to_url import "./utils"; class TributeRange { constructor(tribute) { this.tribute = tribute this.tribute.range = this } getDocument() { let iframe if (this.tribute.current.collection) { iframe = this.tribute.current.collection.ifr...
/content/code_sandbox/src/TributeRange.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
4,294
```javascript class TributeMenuEvents { constructor(tribute) { this.tribute = tribute; this.tribute.menuEvents = this; this.menu = this.tribute.menu; } bind(menu) { this.menuClickEvent = this.tribute.events.click.bind(null, this); this.menuContainerScrollEvent = this.debounce( () => { ...
/content/code_sandbox/src/TributeMenuEvents.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
488
```javascript import "./utils"; import TributeEvents from "./TributeEvents"; import TributeMenuEvents from "./TributeMenuEvents"; import TributeRange from "./TributeRange"; import TributeSearch from "./TributeSearch"; class Tribute { constructor({ values = null, loadingItemTemplate = null, iframe = null,...
/content/code_sandbox/src/Tribute.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
3,473
```javascript /** * Tribute.js * Native ES6 JavaScript @mention Plugin **/ import "./tribute.scss"; import Tribute from "./Tribute"; export default Tribute; ```
/content/code_sandbox/src/index.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
33
```javascript class TributeEvents { constructor(tribute) { this.tribute = tribute; this.tribute.events = this; } static keys() { return [ { key: 9, value: "TAB" }, { key: 8, value: "DELETE" }, { key: 13, value: "ENTER" ...
/content/code_sandbox/src/TributeEvents.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
2,125
```javascript !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Tribute=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(va...
/content/code_sandbox/dist/tribute.min.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
8,133
```css .tribute-container { position: absolute; top: 0; left: 0; height: auto; overflow: auto; display: block; z-index: 999999; } .tribute-container ul { margin: 0; margin-top: 2px; padding: 0; list-style: none; background: #efefef; } .tribute-container li { padding: 5px 5px; cursor: pointer...
/content/code_sandbox/dist/tribute.css
css
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
161
```javascript if (!Array.prototype.find) { Array.prototype.find = function(predicate) { if (this === null) { throw new TypeError('Array.prototype.find called on null or undefined') } if (typeof predicate !== 'function') { throw new TypeError('predicate must be a funct...
/content/code_sandbox/dist/tribute.esm.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
11,448
```javascript (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.Tribute = factory()); }(this, (function () { 'use strict'; function _classCallC...
/content/code_sandbox/dist/tribute.js
javascript
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
14,008
```unknown {"version":3,"file":"tribute.min.js","sources":["../src/utils.js","../src/TributeEvents.js","../src/TributeMenuEvents.js","../src/TributeRange.js","../src/TributeSearch.js","../src/Tribute.js"],"sourcesContent":["if (!Array.prototype.find) {\n Array.prototype.find = function(predicate) {\n if (this...
/content/code_sandbox/dist/tribute.min.js.map
unknown
2016-01-19T00:54:39
2024-08-14T11:30:58
tribute
zurb/tribute
2,017
30,451
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Boolean AND int type IAND struct{ base.NoOperandsInstruction } func (self *IAND) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopInt() v1 := stack.PopInt() result := v1 & v2 stack.PushInt(result) } //...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/and.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
158
```go package classfile /* LineNumberTable_attribute { u2 attribute_name_index; u4 attribute_length; u2 line_number_table_length; { u2 start_pc; u2 line_number; } line_number_table[line_number_table_length]; } */ type LineNumberTableAttribute struct { lineNumberTable []*LineNumberTableEn...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_line_number_table.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
255
```go package instructions import "fmt" import "jvmgo/ch11/instructions/base" import . "jvmgo/ch11/instructions/comparisons" import . "jvmgo/ch11/instructions/constants" import . "jvmgo/ch11/instructions/control" import . "jvmgo/ch11/instructions/conversions" import . "jvmgo/ch11/instructions/extended" import . "jvmgo...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/factory.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
4,240
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Store int into local variable type ISTORE struct{ base.Index8Instruction } func (self *ISTORE) Execute(frame *rtda.Frame) { _istore(frame, uint(self.Index)) } type ISTORE_0 struct{ base.NoOperandsInstruction } func (self *ISTOR...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/istore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
270
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Compare float type FCMPG struct{ base.NoOperandsInstruction } func (self *FCMPG) Execute(frame *rtda.Frame) { _fcmp(frame, true) } type FCMPL struct{ base.NoOperandsInstruction } func (self *FCMPL) Execute(frame *rtda.Fram...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/fcmp.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
217
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Invoke a class (static) method type INVOKE_STATIC struct{ base.Index16Instruction } func (self *INVOKE_STATIC) Execute(frame *rtda.Frame) { cp := frame.Method().Class().ConstantPool() methodRef ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/invokestatic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
174
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch if int comparison with zero succeeds type IFEQ struct{ base.BranchInstruction } func (self *IFEQ) Execute(frame *rtda.Frame) { val := frame.OperandStack().PopInt() if val == 0 { base.Branch(frame, self.Offset) } }...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/ifcond.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
348
```go package conversions import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Convert double to float type D2F struct{ base.NoOperandsInstruction } func (self *D2F) Execute(frame *rtda.Frame) { stack := frame.OperandStack() d := stack.PopDouble() f := float32(d) stack.PushFloat(f) } // Convert dou...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/conversions/d2x.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
206
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Shift left int type ISHL struct{ base.NoOperandsInstruction } func (self *ISHL) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopInt() v1 := stack.PopInt() s := uint32(v2) & 0x1f result := v1 << s stac...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/sh.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
526
```go package extended import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch if reference is null type IFNULL struct{ base.BranchInstruction } func (self *IFNULL) Execute(frame *rtda.Frame) { ref := frame.OperandStack().PopRef() if ref == nil { base.Branch(frame, self.Offset) } } // Branch i...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/extended/ifnull.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
144
```go package classfile /* CONSTANT_Class_info { u1 tag; u2 name_index; } */ type ConstantClassInfo struct { cp ConstantPool nameIndex uint16 } func (self *ConstantClassInfo) readInfo(reader *ClassReader) { self.nameIndex = reader.readUint16() } func (self *ConstantClassInfo) Name() string { return...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_class.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
90
```go package classfile import "fmt" type ConstantPool []ConstantInfo func readConstantPool(reader *ClassReader) ConstantPool { cpCount := int(reader.readUint16()) cp := make([]ConstantInfo, cpCount) // The constant_pool table is indexed from 1 to constant_pool_count - 1. for i := 1; i < cpCount; i++ { cp[i] ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/constant_pool.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
421
```go package extended import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/instructions/loads" import "jvmgo/ch11/instructions/math" import "jvmgo/ch11/instructions/stores" import "jvmgo/ch11/rtda" // Extend local variable index by additional bytes type WIDE struct { modifiedInstruction base.Instruction } func...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/extended/wide.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
511
```go package control import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" /* lookupswitch <0-3 byte pad> defaultbyte1 defaultbyte2 defaultbyte3 defaultbyte4 npairs1 npairs2 npairs3 npairs4 match-offset pairs... */ // Access jump table by key match and jump type LOOKUP_SWITCH struct { defaultOffset int32 ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/control/lookupswitch.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
259
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Create new object type NEW struct{ base.Index16Instruction } func (self *NEW) Execute(frame *rtda.Frame) { cp := frame.Method().Class().ConstantPool() classRef := cp.GetConstant(self.Index).(*he...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/new.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
167
```go package extended import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch always (wide index) type GOTO_W struct { offset int } func (self *GOTO_W) FetchOperands(reader *base.BytecodeReader) { self.offset = int(reader.ReadInt32()) } func (self *GOTO_W) Execute(frame *rtda.Frame) { base.Branc...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/extended/goto_w.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
96
```go package control import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" /* tableswitch <0-3 byte pad> defaultbyte1 defaultbyte2 defaultbyte3 defaultbyte4 lowbyte1 lowbyte2 lowbyte3 lowbyte4 highbyte1 highbyte2 highbyte3 highbyte4 jump offsets... */ // Access jump table by index and jump type TABLE_SWITCH...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/control/tableswitch.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
274
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Increment local variable by constant type IINC struct { Index uint Const int32 } func (self *IINC) FetchOperands(reader *base.BytecodeReader) { self.Index = uint(reader.ReadUint8()) self.Const = int32(reader.ReadInt8()) } func ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/iinc.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
132
```go package stack import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Swap the top two operand stack values type SWAP struct{ base.NoOperandsInstruction } func (self *SWAP) Execute(frame *rtda.Frame) { stack := frame.OperandStack() slot1 := stack.PopSlot() slot2 := stack.PopSlot() stack.PushSlot(...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stack/swap.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
96
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Determine if object is of given type type INSTANCE_OF struct{ base.Index16Instruction } func (self *INSTANCE_OF) Execute(frame *rtda.Frame) { stack := frame.OperandStack() ref := stack.PopRef() ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/instanceof.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
164
```go package classfile /* attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; } */ type UnparsedAttribute struct { name string length uint32 info []byte } func (self *UnparsedAttribute) readInfo(reader *ClassReader) { self.info = reader.readBytes(self.length)...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_unparsed.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
96
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Store into reference array type AASTORE struct{ base.NoOperandsInstruction } func (self *AASTORE) Execute(frame *rtda.Frame) { stack := frame.OperandStack() ref := stack.PopRef() index := stack.Pop...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/xastore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
823
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch if int comparison succeeds type IF_ICMPEQ struct{ base.BranchInstruction } func (self *IF_ICMPEQ) Execute(frame *rtda.Frame) { if val1, val2 := _icmpPop(frame); val1 == val2 { base.Branch(frame, self.Offset) } } t...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/if_icmp.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
430
```go package classfile /* SourceFile_attribute { u2 attribute_name_index; u4 attribute_length; u2 sourcefile_index; } */ type SourceFileAttribute struct { cp ConstantPool sourceFileIndex uint16 } func (self *SourceFileAttribute) readInfo(reader *ClassReader) { self.sourceFileIndex = reade...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_source_file.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
101
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Invoke instance method; // special handling for superclass, private, and instance initialization method invocations type INVOKE_SPECIAL struct{ base.Index16Instruction } func (self *INVOKE_SPECIAL...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/invokespecial.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
403
```go package constants import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Do nothing type NOP struct{ base.NoOperandsInstruction } func (self *NOP) Execute(frame *rtda.Frame) { // really do nothing } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/constants/nop.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
62
```shell #!/bin/sh set -ex cd v1/code/java/jvmgo_java # export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/ sh gradlew ch01:run --args ' -version' | grep -q "1.8.0" sh gradlew ch02:run --args ' java.lang.Object' | grep -q "class data" sh gradlew ch03:run --args ' java.lang.Object' | gre...
/content/code_sandbox/test_java.sh
shell
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
687
```go package main import "fmt" import "strings" import "jvmgo/ch11/classpath" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" type JVM struct { cmd *Cmd classLoader *heap.ClassLoader mainThread *rtda.Thread } func newJVM(cmd *Cmd) *JVM { cp := classpath.Pars...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/jvm.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
434
```go package conversions import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Convert long to double type L2D struct{ base.NoOperandsInstruction } func (self *L2D) Execute(frame *rtda.Frame) { stack := frame.OperandStack() l := stack.PopLong() d := float64(l) stack.PushDouble(d) } // Convert long ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/conversions/l2x.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
206
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Fetch field from object type GET_FIELD struct{ base.Index16Instruction } func (self *GET_FIELD) Execute(frame *rtda.Frame) { cp := frame.Method().Class().ConstantPool() fieldRef := cp.GetConstan...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/getfield.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
275
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Add double type DADD struct{ base.NoOperandsInstruction } func (self *DADD) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v1 := stack.PopDouble() v2 := stack.PopDouble() result := v1 + v2 stack.PushDouble(result) }...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/add.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
290
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Load reference from local variable type ALOAD struct{ base.Index8Instruction } func (self *ALOAD) Execute(frame *rtda.Frame) { _aload(frame, self.Index) } type ALOAD_0 struct{ base.NoOperandsInstruction } func (self *ALOAD_0) Ex...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/aload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
262
```go package constants import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Push null type ACONST_NULL struct{ base.NoOperandsInstruction } func (self *ACONST_NULL) Execute(frame *rtda.Frame) { frame.OperandStack().PushRef(nil) } // Push double type DCONST_0 struct{ base.NoOperandsInstruction } func...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/constants/const.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
688
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Enter monitor for object type MONITOR_ENTER struct{ base.NoOperandsInstruction } // todo func (self *MONITOR_ENTER) Execute(frame *rtda.Frame) { ref := frame.OperandStack().PopRef() if ref == nil { panic("java.lang.NullPoi...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/monitor.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
154
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Create new multidimensional array type MULTI_ANEW_ARRAY struct { index uint16 dimensions uint8 } func (self *MULTI_ANEW_ARRAY) FetchOperands(reader *base.BytecodeReader) { self.index = rea...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/multianewarray.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
373
```go package classfile /* ConstantValue_attribute { u2 attribute_name_index; u4 attribute_length; u2 constantvalue_index; } */ type ConstantValueAttribute struct { constantValueIndex uint16 } func (self *ConstantValueAttribute) readInfo(reader *ClassReader) { self.constantValueIndex = reader.readUint16...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_constant_value.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
95
```go package classfile /* EnclosingMethod_attribute { u2 attribute_name_index; u4 attribute_length; u2 class_index; u2 method_index; } */ type EnclosingMethodAttribute struct { cp ConstantPool classIndex uint16 methodIndex uint16 } func (self *EnclosingMethodAttribute) readInfo(reader *C...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_enclosing_method.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
170
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Load long from local variable type LLOAD struct{ base.Index8Instruction } func (self *LLOAD) Execute(frame *rtda.Frame) { _lload(frame, self.Index) } type LLOAD_0 struct{ base.NoOperandsInstruction } func (self *LLOAD_0) Execute...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/lload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
263
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Boolean OR int type IOR struct{ base.NoOperandsInstruction } func (self *IOR) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopInt() v1 := stack.PopInt() result := v1 | v2 stack.PushInt(result) } // Bo...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/or.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
159
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Load double from local variable type DLOAD struct{ base.Index8Instruction } func (self *DLOAD) Execute(frame *rtda.Frame) { _dload(frame, self.Index) } type DLOAD_0 struct{ base.NoOperandsInstruction } func (self *DLOAD_0) Execu...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/dload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
263
```go package classfile /* Deprecated_attribute { u2 attribute_name_index; u4 attribute_length; } */ type DeprecatedAttribute struct { MarkerAttribute } /* Synthetic_attribute { u2 attribute_name_index; u4 attribute_length; } */ type SyntheticAttribute struct { MarkerAttribute } type MarkerAttribut...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_markers.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
90
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Invoke interface method type INVOKE_INTERFACE struct { index uint // count uint8 // zero uint8 } func (self *INVOKE_INTERFACE) FetchOperands(reader *base.BytecodeReader) { self.index = uint(re...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/invokeinterface.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
349
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Negate double type DNEG struct{ base.NoOperandsInstruction } func (self *DNEG) Execute(frame *rtda.Frame) { stack := frame.OperandStack() val := stack.PopDouble() stack.PushDouble(-val) } // Negate float type FNEG struct{ base.N...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/neg.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
234
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Divide double type DDIV struct{ base.NoOperandsInstruction } func (self *DDIV) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopDouble() v1 := stack.PopDouble() result := v1 / v2 stack.PushDouble(result...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/div.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
334
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" const ( //Array Type atype AT_BOOLEAN = 4 AT_CHAR = 5 AT_FLOAT = 6 AT_DOUBLE = 7 AT_BYTE = 8 AT_SHORT = 9 AT_INT = 10 AT_LONG = 11 ) // Create new array type NEW_ARRAY str...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/newarray.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
368
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Boolean XOR int type IXOR struct{ base.NoOperandsInstruction } func (self *IXOR) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v1 := stack.PopInt() v2 := stack.PopInt() result := v1 ^ v2 stack.PushInt(result) } //...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/xor.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
161
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Subtract double type DSUB struct{ base.NoOperandsInstruction } func (self *DSUB) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopDouble() v1 := stack.PopDouble() result := v1 - v2 stack.PushDouble(resu...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/sub.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
290
```go package constants import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Push item from run-time constant pool type LDC struct{ base.Index8Instruction } func (self *LDC) Execute(frame *rtda.Frame) { _ldc(frame, self.Index) } // Push item from run-time constant pool (w...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/constants/ldc.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
403
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch if reference comparison succeeds type IF_ACMPEQ struct{ base.BranchInstruction } func (self *IF_ACMPEQ) Execute(frame *rtda.Frame) { if _acmp(frame) { base.Branch(frame, self.Offset) } } type IF_ACMPNE struct{ bas...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/if_acmp.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
173
```go package control import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Branch always type GOTO struct{ base.BranchInstruction } func (self *GOTO) Execute(frame *rtda.Frame) { base.Branch(frame, self.Offset) } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/control/goto.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
63
```go package classfile // Constant pool tags const ( CONSTANT_Class = 7 CONSTANT_Fieldref = 9 CONSTANT_Methodref = 10 CONSTANT_InterfaceMethodref = 11 CONSTANT_String = 8 CONSTANT_Integer = 3 CONSTANT_Float = 4 CONSTANT_Long = 5...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/constant_info.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
468
```go package control import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Return void from method type RETURN struct{ base.NoOperandsInstruction } func (self *RETURN) Execute(frame *rtda.Frame) { frame.Thread().PopFrame() } // Return reference from method type ARETURN struct{ base.NoOperandsInstructi...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/control/return.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
454
```go package base import "fmt" import "strings" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" func InvokeMethod(invokerFrame *rtda.Frame, method *heap.Method) { //_logInvoke(callerFrame.Thread().StackDepth(), method) thread := invokerFrame.Thread() newFrame := thread.NewFrame(method) thread.PushFrame(ne...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/base/method_invoke_logic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
218
```go package classfile /* BootstrapMethods_attribute { u2 attribute_name_index; u4 attribute_length; u2 num_bootstrap_methods; { u2 bootstrap_method_ref; u2 num_bootstrap_arguments; u2 bootstrap_arguments[num_bootstrap_arguments]; } bootstrap_methods[num_bootstrap_methods]; } */ ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_bootstrap_methods.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
184
```go package math import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Multiply double type DMUL struct{ base.NoOperandsInstruction } func (self *DMUL) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopDouble() v1 := stack.PopDouble() result := v1 * v2 stack.PushDouble(resu...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/mul.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
290
```go package comparisons import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Compare double type DCMPG struct{ base.NoOperandsInstruction } func (self *DCMPG) Execute(frame *rtda.Frame) { _dcmp(frame, true) } type DCMPL struct{ base.NoOperandsInstruction } func (self *DCMPL) Execute(frame *rtda.Fra...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/comparisons/dcmp.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
217
```shell #!/bin/sh set -ex cd v1/code/go/src/jvmgo # export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/ go run jvmgo/ch01 -version | grep -q "version 0.0.1" go run jvmgo/ch02 java.lang.Object | grep -q "class data" go run jvmgo/ch03 java.lang.Object | grep -q "this class: java/lang/Obj...
/content/code_sandbox/test.sh
shell
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
604
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Get length of array type ARRAY_LENGTH struct{ base.NoOperandsInstruction } func (self *ARRAY_LENGTH) Execute(frame *rtda.Frame) { stack := frame.OperandStack() arrRef := stack.PopRef() if arrRef == nil { panic("java.lang....
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/arraylength.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
104
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Load int from local variable type ILOAD struct{ base.Index8Instruction } func (self *ILOAD) Execute(frame *rtda.Frame) { _iload(frame, self.Index) } type ILOAD_0 struct{ base.NoOperandsInstruction } func (self *ILOAD_0) Execute(...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/iload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
262
```go package base type BytecodeReader struct { code []byte // bytecodes pc int } func (self *BytecodeReader) Reset(code []byte, pc int) { self.code = code self.pc = pc } func (self *BytecodeReader) PC() int { return self.pc } func (self *BytecodeReader) ReadInt8() int8 { return int8(self.ReadUint8()) } fun...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/base/bytecode_reader.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
376
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Store float into local variable type FSTORE struct{ base.Index8Instruction } func (self *FSTORE) Execute(frame *rtda.Frame) { _fstore(frame, uint(self.Index)) } type FSTORE_0 struct{ base.NoOperandsInstruction } func (self *FST...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/fstore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
265
```go package classfile import "fmt" /* ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/class_file.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
845
```go package classfile import "math" /* CONSTANT_Integer_info { u1 tag; u4 bytes; } */ type ConstantIntegerInfo struct { val int32 } func (self *ConstantIntegerInfo) readInfo(reader *ClassReader) { bytes := reader.readUint32() self.val = int32(bytes) } func (self *ConstantIntegerInfo) Value() int32 { re...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_numeric.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
341
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Store double into local variable type DSTORE struct{ base.Index8Instruction } func (self *DSTORE) Execute(frame *rtda.Frame) { _dstore(frame, uint(self.Index)) } type DSTORE_0 struct{ base.NoOperandsInstruction } func (self *DS...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/dstore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
265
```go package stores import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Store reference into local variable type ASTORE struct{ base.Index8Instruction } func (self *ASTORE) Execute(frame *rtda.Frame) { _astore(frame, uint(self.Index)) } type ASTORE_0 struct{ base.NoOperandsInstruction } func (self ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stores/astore.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
265
```go package classfile import "fmt" import "unicode/utf16" /* CONSTANT_Utf8_info { u1 tag; u2 length; u1 bytes[length]; } */ type ConstantUtf8Info struct { str string } func (self *ConstantUtf8Info) readInfo(reader *ClassReader) { length := uint32(reader.readUint16()) bytes := reader.readBytes(length...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_utf8.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
702
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Get static field from class type GET_STATIC struct{ base.Index16Instruction } func (self *GET_STATIC) Execute(frame *rtda.Frame) { cp := frame.Method().Class().ConstantPool() fieldRef := cp.GetC...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/getstatic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
290
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Invoke instance method; dispatch based on class type INVOKE_VIRTUAL struct{ base.Index16Instruction } func (self *INVOKE_VIRTUAL) Execute(frame *rtda.Frame) { currentClass := frame.Method().Class...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/invokevirtual.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
331
```go package base import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // jvms 5.5 func InitClass(thread *rtda.Thread, class *heap.Class) { class.StartInit() scheduleClinit(thread, class) initSuperClass(thread, class) } func scheduleClinit(thread *rtda.Thread, class *heap.Class) { clinit := class.GetClinitMet...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/base/class_init_logic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
199
```go package loads import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Load reference from array type AALOAD struct{ base.NoOperandsInstruction } func (self *AALOAD) Execute(frame *rtda.Frame) { stack := frame.OperandStack() index := stack.PopInt() arrRef := stack.PopR...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/loads/xaload.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
766
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Set static field in class type PUT_STATIC struct{ base.Index16Instruction } func (self *PUT_STATIC) Execute(frame *rtda.Frame) { currentMethod := frame.Method() currentClass := currentMethod.Cla...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/putstatic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
342
```go package reserved import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/native" import _ "jvmgo/ch11/native/java/io" import _ "jvmgo/ch11/native/java/lang" import _ "jvmgo/ch11/native/java/security" import _ "jvmgo/ch11/native/java/util/concurrent/atomic" import _ "jvmgo/ch11/native/su...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/reserved/invokenative.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
244
```go package classfile /* Signature_attribute { u2 attribute_name_index; u4 attribute_length; u2 signature_index; } */ type SignatureAttribute struct { cp ConstantPool signatureIndex uint16 } func (self *SignatureAttribute) readInfo(reader *ClassReader) { self.signatureIndex = reader.readU...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_signature.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
94
```go package math import "math" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Remainder double type DREM struct{ base.NoOperandsInstruction } func (self *DREM) Execute(frame *rtda.Frame) { stack := frame.OperandStack() v2 := stack.PopDouble() v1 := stack.PopDouble() result := math.Mod(v1, v2...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/math/rem.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
358
```go package constants import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Push byte type BIPUSH struct { val int8 } func (self *BIPUSH) FetchOperands(reader *base.BytecodeReader) { self.val = reader.ReadInt8() } func (self *BIPUSH) Execute(frame *rtda.Frame) { i := int32(self.val) frame.OperandSt...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/constants/ipush.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
177
```go package conversions import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Convert float to double type F2D struct{ base.NoOperandsInstruction } func (self *F2D) Execute(frame *rtda.Frame) { stack := frame.OperandStack() f := stack.PopFloat() d := float64(f) stack.PushDouble(d) } // Convert flo...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/conversions/f2x.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
206
```go package classfile /* field_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; } method_info { u2 access_flags; u2 name_index; u2 ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/member_info.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
662
```go package stack import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Pop the top operand stack value type POP struct{ base.NoOperandsInstruction } func (self *POP) Execute(frame *rtda.Frame) { stack := frame.OperandStack() stack.PopSlot() } // Pop the top one or two operand stack values type POP2...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stack/pop.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
125
```go package main import "fmt" import "jvmgo/ch11/instructions" import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" func interpret(thread *rtda.Thread, logInst bool) { defer catchErr(thread) loop(thread, logInst) } func catchErr(thread *rtda.Thread) { if r := recover(); r != nil { logFrames(thread) ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/interpreter.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
393
```go package base import "jvmgo/ch11/rtda" type Instruction interface { FetchOperands(reader *BytecodeReader) Execute(frame *rtda.Frame) } type NoOperandsInstruction struct { // empty } func (self *NoOperandsInstruction) FetchOperands(reader *BytecodeReader) { // nothing to do } type BranchInstruction struct ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/base/instruction.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
191
```go package classfile /* LocalVariableTable_attribute { u2 attribute_name_index; u4 attribute_length; u2 local_variable_table_length; { u2 start_pc; u2 length; u2 name_index; u2 descriptor_index; u2 index; } local_variable_table[local_variable_table_length]; } */...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/attr_local_variable_table.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
251
```go package classfile import "encoding/binary" type ClassReader struct { data []byte } // u1 func (self *ClassReader) readUint8() uint8 { val := self.data[0] self.data = self.data[1:] return val } // u2 func (self *ClassReader) readUint16() uint16 { val := binary.BigEndian.Uint16(self.data) self.data = self...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/class_reader.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
262
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Create new array of reference type ANEW_ARRAY struct{ base.Index16Instruction } func (self *ANEW_ARRAY) Execute(frame *rtda.Frame) { cp := frame.Method().Class().ConstantPool() classRef := cp.Ge...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/anewarray.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
214
```go package main import "flag" import "fmt" import "os" // java [-options] class [args...] type Cmd struct { helpFlag bool versionFlag bool verboseClassFlag bool verboseInstFlag bool cpOption string XjreOption string class string args []string } func parse...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/cmd.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
328
```go package references import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" import "jvmgo/ch11/rtda/heap" // Check whether object is of given type type CHECK_CAST struct{ base.Index16Instruction } func (self *CHECK_CAST) Execute(frame *rtda.Frame) { stack := frame.OperandStack() ref := stack.PopRef() ...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/references/checkcast.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
153
```go package base import "jvmgo/ch11/rtda" func Branch(frame *rtda.Frame, offset int) { pc := frame.Thread().PC() nextPC := pc + offset frame.SetNextPC(nextPC) } ```
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/base/branch_logic.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
50
```go package classfile /* CONSTANT_NameAndType_info { u1 tag; u2 name_index; u2 descriptor_index; } */ type ConstantNameAndTypeInfo struct { nameIndex uint16 descriptorIndex uint16 } func (self *ConstantNameAndTypeInfo) readInfo(reader *ClassReader) { self.nameIndex = reader.readUint16() self.d...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/classfile/cp_name_and_type.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
88
```go package stack import "jvmgo/ch11/instructions/base" import "jvmgo/ch11/rtda" // Duplicate the top operand stack value type DUP struct{ base.NoOperandsInstruction } func (self *DUP) Execute(frame *rtda.Frame) { stack := frame.OperandStack() slot := stack.PopSlot() stack.PushSlot(slot) stack.PushSlot(slot) }...
/content/code_sandbox/v1/code/go/src/jvmgo/ch11/instructions/stack/dup.go
go
2016-01-06T13:13:45
2024-08-16T13:42:58
jvmgo-book
zxh0/jvmgo-book
1,605
584