Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abonie committed Aug 20, 2017
1 parent a65bac8 commit 1dcc649
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 109 deletions.
216 changes: 108 additions & 108 deletions batavia/VirtualMachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,15 +758,15 @@ VirtualMachine.prototype.unpack_code = function(code) {
if (constants.BATAVIA_MAGIC === constants.BATAVIA_MAGIC_36) {
// Python 3.6+, 2-byte opcodes

var pos = 0
var unpacked_code = []
var args = []
var extra = 0
let pos = 0
let unpacked_code = []
let args = []
let extra = 0

while (pos < code.co_code.val.length) {
var opcode_start_pos = pos
let opcode_start_pos = pos

var opcode = code.co_code.val[pos++]
let opcode = code.co_code.val[pos++]

// next opcode has 4-byte argument effectively.
if (opcode === dis.EXTENDED_ARG) {
Expand All @@ -781,7 +781,7 @@ VirtualMachine.prototype.unpack_code = function(code) {
continue
}

var intArg = code.co_code.val[pos++] | extra
let intArg = code.co_code.val[pos++] | extra
extra = 0

if (opcode >= dis.HAVE_ARGUMENT) {
Expand All @@ -791,7 +791,7 @@ VirtualMachine.prototype.unpack_code = function(code) {
if (intArg < code.co_cellvars.length) {
args = [code.co_cellvars[intArg]]
} else {
var var_idx = intArg - code.co_cellvars.length
let var_idx = intArg - code.co_cellvars.length
args = [code.co_freevars[var_idx]]
}
} else if (opcode in dis.hasname) {
Expand Down Expand Up @@ -820,95 +820,95 @@ VirtualMachine.prototype.unpack_code = function(code) {
} else {
// Until 3.6 Python had variable width opcodes

var pos = 0
var unpacked_code = []
var args
var extra = 0
var lo
var hi

while (pos < code.co_code.val.length) {
var opcode_start_pos = pos

var opcode = code.co_code.val[pos++]

// next opcode has 4-byte argument effectively.
if (opcode === dis.EXTENDED_ARG) {
lo = code.co_code.val[pos++]
hi = code.co_code.val[pos++]
extra = (lo << 16) | (hi << 24)
// emulate four NOPs
unpacked_code[opcode_start_pos] = {
'opoffset': opcode_start_pos,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 1] = {
'opoffset': opcode_start_pos + 1,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 2] = {
'opoffset': opcode_start_pos + 2,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 3] = {
'opoffset': opcode_start_pos + 3,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
continue
}

if (opcode < dis.HAVE_ARGUMENT) {
args = []
} else {
lo = code.co_code.val[pos++]
hi = code.co_code.val[pos++]
var intArg = lo | (hi << 8) | extra
extra = 0 // use extended arg if present

if (opcode in dis.hasconst) {
args = [code.co_consts[intArg]]
} else if (opcode in dis.hasfree) {
if (intArg < code.co_cellvars.length) {
args = [code.co_cellvars[intArg]]
} else {
var var_idx = intArg - code.co_cellvars.length
args = [code.co_freevars[var_idx]]
}
} else if (opcode in dis.hasname) {
args = [code.co_names[intArg]]
} else if (opcode in dis.hasjrel) {
args = [pos + intArg]
} else if (opcode in dis.hasjabs) {
args = [intArg]
} else if (opcode in dis.haslocal) {
args = [code.co_varnames[intArg]]
} else {
args = [intArg]
}
}

unpacked_code[opcode_start_pos] = {
'opoffset': opcode_start_pos,
'opcode': opcode,
'op_method': this.dispatch_table[opcode],
'args': args,
'next_pos': pos
}
}

code.co_unpacked_code = unpacked_code
let pos = 0
let unpacked_code = []
let args
let extra = 0
let lo
let hi

while (pos < code.co_code.val.length) {
let opcode_start_pos = pos

let opcode = code.co_code.val[pos++]

// next opcode has 4-byte argument effectively.
if (opcode === dis.EXTENDED_ARG) {
lo = code.co_code.val[pos++]
hi = code.co_code.val[pos++]
extra = (lo << 16) | (hi << 24)
// emulate four NOPs
unpacked_code[opcode_start_pos] = {
'opoffset': opcode_start_pos,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 1] = {
'opoffset': opcode_start_pos + 1,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 2] = {
'opoffset': opcode_start_pos + 2,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
unpacked_code[opcode_start_pos + 3] = {
'opoffset': opcode_start_pos + 3,
'opcode': dis.NOP,
'op_method': this.dispatch_table[dis.NOP],
'args': [],
'next_pos': pos
}
continue
}

if (opcode < dis.HAVE_ARGUMENT) {
args = []
} else {
lo = code.co_code.val[pos++]
hi = code.co_code.val[pos++]
let intArg = lo | (hi << 8) | extra
extra = 0 // use extended arg if present

if (opcode in dis.hasconst) {
args = [code.co_consts[intArg]]
} else if (opcode in dis.hasfree) {
if (intArg < code.co_cellvars.length) {
args = [code.co_cellvars[intArg]]
} else {
let var_idx = intArg - code.co_cellvars.length
args = [code.co_freevars[var_idx]]
}
} else if (opcode in dis.hasname) {
args = [code.co_names[intArg]]
} else if (opcode in dis.hasjrel) {
args = [pos + intArg]
} else if (opcode in dis.hasjabs) {
args = [intArg]
} else if (opcode in dis.haslocal) {
args = [code.co_varnames[intArg]]
} else {
args = [intArg]
}
}

unpacked_code[opcode_start_pos] = {
'opoffset': opcode_start_pos,
'opcode': opcode,
'op_method': this.dispatch_table[opcode],
'args': args,
'next_pos': pos
}
}

code.co_unpacked_code = unpacked_code
}
}

Expand Down Expand Up @@ -1949,30 +1949,30 @@ VirtualMachine.prototype.byte_CALL_FUNCTION_VAR_KW = function(arg) {

VirtualMachine.prototype.call_function = function(arg, args, kwargs) {
if (constants.BATAVIA_MAGIC === constants.BATAVIA_MAGIC_36) {
var namedargs = new types.JSDict()
var lenPos = arg
let namedargs = new types.JSDict()
let lenPos = arg
if (kwargs) {
for (let kv of kwargs.items()) {
namedargs[kv[0]] = kv[1]
}
}
var posargs = this.popn(lenPos)
let posargs = this.popn(lenPos)
if (args) {
for (let elem of args) {
posargs.push(elem)
}
}
var func = this.pop()
let func = this.pop()
if (func.__call__ !== undefined) {
func = func.__call__.bind(func)
}

var retval = func(posargs, namedargs)
let retval = func(posargs, namedargs)
this.push(retval)
} else {
var namedargs = new types.JSDict()
var lenKw = Math.floor(arg / 256)
var lenPos = arg % 256
let namedargs = new types.JSDict()
let lenKw = Math.floor(arg / 256)
let lenPos = arg % 256
for (var i = 0; i < lenKw; i++) {
var items = this.popn(2)
namedargs[items[0]] = items[1]
Expand All @@ -1982,18 +1982,18 @@ VirtualMachine.prototype.call_function = function(arg, args, kwargs) {
namedargs[kv[0]] = kv[1]
}
}
var posargs = this.popn(lenPos)
let posargs = this.popn(lenPos)
if (args) {
for (let elem of args) {
posargs.push(elem)
}
}
var func = this.pop()
let func = this.pop()
if (func.__call__ !== undefined) {
func = func.__call__.bind(func)
}

var retval = func(posargs, namedargs)
let retval = func(posargs, namedargs)
this.push(retval)
}
}
Expand Down
2 changes: 1 addition & 1 deletion batavia/types/Bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Bytes.prototype.__or__ = function(other) {

Bytes.prototype.__ifloordiv__ = function(other) {
var types = require('../types')

if (types.isinstance(other, [types.Complex])) {
throw new exceptions.TypeError.$pyclass("can't take floor of complex number.")
} else {
Expand Down

0 comments on commit 1dcc649

Please sign in to comment.