Module Expr Call NameLoad Str FunctionDef arguments args NameParam defaults body With NameLoad body Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body If CompareEq Call NameLoad NameLoad Str body Return Call AttributeLoad NameLoad attr NameLoad orelse Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body Return SubscriptLoad NameLoad Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareEq NameLoad NameLoad body Return NameLoad orelse If AttributeLoad NameLoad attr body If CompareEq AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr body Return NameLoad orelse Return NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Num For NameStore NameLoad body AugAssignAdd NameStore NameLoad Return NameLoad decorator_list ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam defaults body With NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Assign NameStore AttributeLoad NameLoad attr AugAssignAdd AttributeStore NameLoad attr Num Return Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpAdd NameLoad Num BinOpAdd NameLoad Num decorator_list decorator_list ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Assign NameStore AttributeLoad NameLoad attr AugAssignAdd AttributeStore NameLoad attr Num Return SubscriptLoad SubscriptLoad AttributeLoad NameLoad attr Ellipsis Index BinOpAdd NameLoad Num decorator_list decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad Num body With NameLoad body Assign AttributeStore NameLoad attr NameLoad If CompareEq Call NameLoad NameLoad Str body Assign SubscriptStore NameLoad Ellipsis Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpAnd CompareEq Call NameLoad NameLoad Str AttributeLoad NameLoad attr CompareEq AttributeLoad AttributeLoad NameLoad attr attr Str body Print Str orelse If NameLoad body Assign SubscriptStore NameLoad Ellipsis NameLoad orelse Assign SubscriptStore NameLoad Ellipsis Dict decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body For NameStore SubscriptLoad NameLoad Ellipsis body If CompareEq NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body If CompareLt NameLoad Num body Assign NameStore BinOpAdd AttributeLoad NameLoad attr NameLoad Return SubscriptLoad SubscriptLoad NameLoad Ellipsis Index BinOpAdd NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body With NameLoad body If CompareLt NameLoad Num body Assign NameStore BinOpAdd AttributeLoad NameLoad attr NameLoad Assign SubscriptStore SubscriptLoad NameLoad Ellipsis Index BinOpAdd NameLoad Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body If BoolOpAnd CompareEq NameLoad NameLoad CompareEq NameLoad NameLoad body With NameLoad body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Ellipsis Return Call NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr orelse If CompareLt NameLoad Num body Pass decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Ellipsis Assign NameStore Call NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body AugAssignAdd AttributeStore NameLoad attr Num Assign SubscriptStore SubscriptLoad NameLoad Ellipsis Index AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body Assign NameStore Num While CompareLt NameLoad AttributeLoad NameLoad attr body If CompareEq SubscriptLoad SubscriptLoad NameLoad Ellipsis Index BinOpAdd NameLoad Num NameLoad body Return NameLoad AugAssignAdd NameStore Num decorator_list decorator_list Assign NameStore NameLoad Expr Call NameLoad Str FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareIsNot NameLoad NameLoad body Assign NameStore NameLoad Assign NameStore NameLoad orelse Assign NameStore Num Assign NameStore ListLoad While CompareLt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Num Return NameLoad decorator_list ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body With NameLoad body Assign SubscriptStore NameLoad Ellipsis Dict If NameLoad body Assign SubscriptStore NameLoad Ellipsis NameLoad orelse If NameLoad body For NameStore NameLoad body Assign SubscriptStore SubscriptLoad NameLoad Ellipsis Index AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body With NameLoad body Return SubscriptLoad SubscriptLoad NameLoad Ellipsis Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body With NameLoad body Assign SubscriptStore SubscriptLoad NameLoad Ellipsis Index NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Assign NameStore ListLoad Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Ellipsis body Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign NameStore BinOpAdd NameLoad Num Return Call NameLoad keyword NameLoad keyword BinOpSub NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad Call AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body With NameLoad body Assign NameStore ListLoad Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Ellipsis body Assign NameStore ListLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad Dict NameLoad NameLoad NameLoad Num Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign NameStore BinOpAdd NameLoad Num Return Call NameLoad keyword NameLoad keyword BinOpSub NameLoad Num decorator_list decorator_list
N/A N/A N/A JS 

local __bitops__ = require('bit')
__NULL_OBJECT__ = {}

__concat_tables_array = function(t1, t2)
	for i=1,#t2 do
		t1[ #t1+1 ] = t2[i]
	end
	return t1
end

__concat_tables = function(t1, t2)
	for k,v in pairs(t2) do
		t1[k] = v
	end
	return t1
end

function table.shallow_copy(t)
	local t2 = {}
	for k,v in pairs(t) do
		t2[k] = v
	end
	return t2
end

__test_if_true__ = function( x )
	if x == true then return true
	elseif x == false then return false
	elseif x == nil then return false
	elseif x == '' then return false

	elseif type(x) == 'number' then
		if x == 0 then return false
		else return true
		end

	elseif x.__class__ and x.__class__.__name__ == 'list' then
		if x.length > 0 then return true
		else return false end
	elseif x.__class__ and x.__class__.__name__ == 'dict' then
		if x.keys().length > 0 then return true
		else return false end
	else
		return true
	end
end

__set__ = function(ob, name, value)
	ob[ name ] = value
end

__get__ = function(ob, name)
	if name == '__call__' then
		if type(ob)=='function' then
			return ob
		else
			return ob.__call__
		end
	elseif type(ob)=='string' then
		return __get__helper_string(ob,name)
	elseif ob.__getters__ and ob.__getters__[name] then
		return ob.__getters__[name]( ob )  --unbound method--
	elseif ob[name]==nil and ob.__getattr__ then
		return ob.__getattr__( {name} )
	else
		return ob[ name ]
	end
end

__sprintf = function(s, args)
	if type(args)=='table' then
		return string.format(s, unpack(args))
	else
		return string.format(s, args)
	end
end

function string:to_array()
	local i = 1
	local t = {}
	for c in self:gmatch('.') do
		t[ i ] = c
		i = i + 1
	end
	return t
end

function string:split(sSeparator, nMax, bRegexp)
	assert(sSeparator ~= '')
	assert(nMax == nil or nMax >= 1)
	if sSeparator == nil then
		sSeparator = ' '
	end

	local aRecord = {}

	if self:len() > 0 then
		local bPlain = not bRegexp
		nMax = nMax or -1

		local nField=1 nStart=1
		local nFirst,nLast = self:find(sSeparator, nStart, bPlain)
		while nFirst and nMax ~= 0 do
			aRecord[nField] = self:sub(nStart, nFirst-1)
			nField = nField+1
			nStart = nLast+1
			nFirst,nLast = self:find(sSeparator, nStart, bPlain)
			nMax = nMax-1
		end
		aRecord[nField] = self:sub(nStart)
	end
	return aRecord
end

__bind_methods__ = function(object, class)
	for k,v in pairs( class.__attributes__ ) do
		if object[k] == nil then
			if type(v)=='function' then
				object[ k ] = function(_args, _kwargs)
					local o = {object}
					if _args then
						return v(__concat_tables_array(o, _args), _kwargs or {})
					else
						return v(o, _kwargs or {})
					end
				end
			else
				-- TODO class attribute should have dynamic look up.
				object[ k ] = v
			end
		end
	end
	for k,v in pairs( class.__bases__ ) do
		__bind_methods__( object, v )
	end
end

__bind_properties__ = function(object, class)
	for k,v in pairs( class.__properties__ ) do
		assert( type(v.get)=='function' )
		if object.__getters__[k] == nil then
			object.__getters__[k] = v.get   --unbound method--
		end
	end
	for k,v in pairs( class.__bases__ ) do
		__bind_properties__( object, v )
	end
end


__create_class__ = function(class_name, parents, attrs, props)
	local class = {
		__bases__ = parents,
		__name__ = class_name,
		__properties__ = props,
		__attributes__ = attrs
	}
	function class.__call__( args, kwargs )
		local object = {
			__class__ = class,
			__dict__ = 'TODO',
			__getters__ = {}
		}
		__bind_methods__( object, class )
		__bind_properties__( object, class )

		for k,v in pairs( class.__attributes__ ) do
			class[ k ] = v
		end

		if object.__init__ then
			object.__init__( args, kwargs )
		end
		return object
	end
	return class
end


__add_op = function(a,b)
	if type(a) == 'string' then
		return a .. b
	elseif type(a) == 'table' and a.__class__ then
		return a.__add__({b}, {})
	else
		return a + b
	end
end

__add__ = function(a,b)
	if type(a) == 'string' then
		return a .. b
	else
		return a + b
	end
end

 str N/A N/A ob N/A N/A N/A lowlevel N/A N/A N/A tostring ob N/A int N/A N/A ob N/A N/A N/A lowlevel N/A N/A N/A tonumber ob N/A float N/A N/A ob N/A N/A N/A lowlevel N/A N/A N/A tonumber ob N/A len N/A N/A ob N/A N/A N/A lowlevel N/A N/A N/A N/A type ob string N/A N/A N/A N/A string len ob N/A N/A N/A ob length N/A chr N/A N/A a N/A N/A N/A lowlevel N/A N/A N/A N/A string char a N/A ord N/A N/A a N/A N/A N/A lowlevel N/A N/A N/A N/A string byte a N/A getattr N/A N/A ob name N/A N/A N/A lowlevel N/A N/A N/A ob N/A name N/A isinstance N/A N/A ob klass N/A N/A N/A N/A ob None N/A N/A False N/A N/A N/A ob __class__ N/A N/A N/A N/A N/A ob __class__ __name__ N/A klass __name__ N/A N/A True N/A N/A False N/A N/A False N/A sum N/A N/A arr N/A N/A N/A a 0 N/A b arr N/A N/A a b N/A a N/A __iterator_string N/A N/A __init__ N/A N/A self obj index N/A N/A N/A lowlevel N/A N/A N/A self obj obj N/A N/A self index index N/A N/A self length N/A N/A string len obj N/A next N/A N/A self N/A N/A N/A lowlevel N/A N/A index N/A self index N/A N/A self index 1 N/A N/A N/A string sub N/A self obj N/A index 1 N/A index 1 N/A N/A __iterator_list N/A N/A __init__ N/A N/A self obj index N/A N/A N/A N/A self obj obj N/A N/A self index index N/A N/A self length N/A len obj N/A next N/A N/A self N/A N/A N/A lowlevel N/A N/A index N/A self index N/A N/A self index 1 N/A N/A N/A N/A self obj N/A N/A N/A index 1 N/A N/A list N/A N/A N/A 
	Array length in Lua must be manually tracked, because a normal for loop will not
	properly loop over a sparse Array with nil holes.
	 __init__ N/A N/A self items pointer length N/A None 0 N/A N/A lowlevel N/A N/A N/A self length length N/A N/A N/A type items string N/A N/A N/A self N/A N/A N/A string to_array items N/A N/A self length N/A N/A string len items N/A N/A N/A N/A N/A type items table N/A items __class__ N/A N/A N/A items __class__ __name__ list N/A N/A HIT TABLE!!! N/A N/A pointer N/A N/A N/A self N/A pointer N/A N/A N/A self N/A N/A N/A __contains__ N/A N/A self value N/A N/A N/A lowlevel N/A N/A v N/A self N/A N/A N/A N/A v value N/A N/A True N/A False N/A __getitem__ N/A N/A self index N/A N/A N/A lowlevel N/A N/A N/A index 0 N/A N/A index N/A N/A self length index N/A N/A N/A self N/A N/A N/A index 1 N/A __setitem__ N/A N/A self index value N/A N/A N/A lowlevel N/A N/A N/A index 0 N/A N/A index N/A N/A self length index N/A N/A N/A self N/A N/A N/A index 1 value N/A __getslice__ N/A N/A self start stop step N/A N/A N/A N/A N/A stop None N/A step None N/A N/A lowlevel N/A N/A copy N/A N/A table shallow_copy N/A self N/A N/A N/A list pointer copy length N/A self length N/A N/A N/A stop 0 N/A N/A N/A __iter__ N/A N/A self N/A N/A N/A N/A __iterator_list self 0 N/A __add__ N/A N/A self other N/A N/A N/A lowlevel N/A N/A ptr N/A N/A table shallow_copy N/A self N/A N/A copy N/A list pointer ptr length N/A self length N/A item other N/A N/A N/A N/A copy append item N/A copy N/A append N/A N/A self item N/A N/A N/A lowlevel N/A N/A N/A self length 1 N/A N/A N/A self N/A N/A N/A self length item N/A index N/A N/A self obj N/A N/A N/A lowlevel N/A N/A i 0 N/A N/A i N/A self length N/A N/A N/A N/A N/A self N/A N/A N/A i 1 obj N/A N/A i N/A i 1 N/A N/A N/A tuple list N/A N/A JS 

__create_list = function(size)
	return __get__(list, "__call__")({}, {pointer={},length=size})
end

__get__helper_string = function(s, name)
	local wrapper
	if name == '__getitem__' then
		wrapper = function(args, kwargs)
			return string.sub(s, args[1]+1, args[1]+1)
		end

	elseif name == '__contains__' then
		wrapper = function(args, kwargs)
			if s:find( args[1] ) then return true
			else return false end
		end

	elseif name == '__getslice__' then
		wrapper = function(args, kwargs)
			if args[1]==nil and args[2]==nil and args[3]==-1 then
				return s:reverse()
			end
		end

	elseif name == '__iter__' then
		wrapper = function(args, kwargs)
			return __iterator_string.__call__( {s, 0} )
		end

	elseif name == 'upper' then
		wrapper = function(args, kwargs)
			return string.upper(s)
		end
	elseif name == 'lower' then
		wrapper = function(args, kwargs)
			return string.lower(s)
		end
	elseif name == 'split' then
		wrapper = function(args, kwargs)
			local a
			if args then
				a = s:split( args[1] )
			else
				a = s:split()
			end
			return list.__call__( {}, {pointer=a, length=#a} )
		end
	else
		print('ERROR: NotImplemented')
	end

	return wrapper
end
 range N/A N/A num stop N/A N/A N/A Emulates Python's range function N/A N/A stop None N/A N/A i num N/A num stop N/A N/A i 0 N/A arr N/A N/A N/A i num N/A N/A N/A N/A arr append i N/A i 1 N/A arr N/A dict N/A N/A __init__ N/A N/A self object pointer N/A None N/A N/A lowlevel N/A N/A N/A self N/A N/A N/A pointer N/A N/A N/A self N/A pointer N/A N/A object N/A N/A d object N/A N/A N/A N/A self N/A N/A N/A d key N/A d value N/A __getitem__ N/A N/A self key N/A N/A N/A lowlevel N/A N/A N/A N/A self N/A N/A key N/A __setitem__ N/A N/A self key value N/A N/A N/A lowlevel N/A N/A N/A N/A self N/A N/A key value N/A keys N/A N/A self N/A N/A N/A lowlevel N/A N/A ptr N/A N/A i 1 N/A N/A k v N/A pairs N/A self N/A N/A N/A N/A ptr N/A i k N/A i N/A i 1 N/A N/A list pointer ptr length N/A i 1 N/A __iter__ N/A N/A self N/A N/A N/A N/A N/A N/A N/A self keys __iter__ N/A items N/A N/A self N/A N/A N/A lowlevel N/A N/A ptr N/A N/A i 1 N/A N/A k v N/A pairs N/A self N/A N/A N/A p N/A k v N/A item N/A N/A list __call__ N/A N/A pointer length p 2 N/A N/A ptr N/A i item N/A i N/A i 1 N/A N/A list pointer ptr length N/A i 1 N/A N/A