Reorder and rename for consistency
This commit is contained in:
		
							parent
							
								
									64ddfd03f9
								
							
						
					
					
						commit
						2363811773
					
				| @ -48,16 +48,16 @@ do | |||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function add.i32(a, b) | 	function add.i32(lhs, rhs) | ||||||
| 		return (to_signed(a + b)) | 		return (to_signed(lhs + rhs)) | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function sub.i32(a, b) | 	function sub.i32(lhs, rhs) | ||||||
| 		return (to_signed(a - b)) | 		return (to_signed(lhs - rhs)) | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function mul.i32(a, b) | 	function mul.i32(lhs, rhs) | ||||||
| 		return (to_signed(ID_ONE * a * b)) | 		return (to_signed(ID_ONE * lhs * rhs)) | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function div.i32(lhs, rhs) | 	function div.i32(lhs, rhs) | ||||||
| @ -270,7 +270,7 @@ do | |||||||
| 	local demote = {} | 	local demote = {} | ||||||
| 	local reinterpret = {} | 	local reinterpret = {} | ||||||
| 
 | 
 | ||||||
| 	local bit_band = bit.band | 	local bit_and = bit.band | ||||||
| 
 | 
 | ||||||
| 	-- This would surely be an issue in a multi-thread environment... | 	-- This would surely be an issue in a multi-thread environment... | ||||||
| 	-- ... thankfully this isn't one. | 	-- ... thankfully this isn't one. | ||||||
| @ -297,7 +297,7 @@ do | |||||||
| 	trunc.u64_f64 = i64 | 	trunc.u64_f64 = i64 | ||||||
| 
 | 
 | ||||||
| 	function extend.i32_i8(num) | 	function extend.i32_i8(num) | ||||||
| 		num = bit_band(num, 0xFF) | 		num = bit_and(num, 0xFF) | ||||||
| 
 | 
 | ||||||
| 		if num >= 0x80 then | 		if num >= 0x80 then | ||||||
| 			return num - 0x100 | 			return num - 0x100 | ||||||
| @ -307,7 +307,7 @@ do | |||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function extend.i32_i16(num) | 	function extend.i32_i16(num) | ||||||
| 		num = bit_band(num, 0xFFFF) | 		num = bit_and(num, 0xFFFF) | ||||||
| 
 | 
 | ||||||
| 		if num >= 0x8000 then | 		if num >= 0x8000 then | ||||||
| 			return num - 0x10000 | 			return num - 0x10000 | ||||||
| @ -317,7 +317,7 @@ do | |||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function extend.i64_i8(num) | 	function extend.i64_i8(num) | ||||||
| 		num = bit_band(num, 0xFF) | 		num = bit_and(num, 0xFF) | ||||||
| 
 | 
 | ||||||
| 		if num >= 0x80 then | 		if num >= 0x80 then | ||||||
| 			return num - 0x100 | 			return num - 0x100 | ||||||
| @ -327,7 +327,7 @@ do | |||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function extend.i64_i16(num) | 	function extend.i64_i16(num) | ||||||
| 		num = bit_band(num, 0xFFFF) | 		num = bit_and(num, 0xFFFF) | ||||||
| 
 | 
 | ||||||
| 		if num >= 0x8000 then | 		if num >= 0x8000 then | ||||||
| 			return num - 0x10000 | 			return num - 0x10000 | ||||||
| @ -337,7 +337,7 @@ do | |||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function extend.i64_i32(num) | 	function extend.i64_i32(num) | ||||||
| 		num = bit_band(num, 0xFFFFFFFF) | 		num = bit_and(num, 0xFFFFFFFF) | ||||||
| 
 | 
 | ||||||
| 		if num >= 0x80000000 then | 		if num >= 0x80000000 then | ||||||
| 			return num - 0x100000000 | 			return num - 0x100000000 | ||||||
|  | |||||||
| @ -57,28 +57,28 @@ do | |||||||
| 	local math_floor = math.floor | 	local math_floor = math.floor | ||||||
| 	local math_round = math.round | 	local math_round = math.round | ||||||
| 	local math_sign = math.sign | 	local math_sign = math.sign | ||||||
| 	local math_max = math.max |  | ||||||
| 	local math_min = math.min | 	local math_min = math.min | ||||||
|  | 	local math_max = math.max | ||||||
| 
 | 
 | ||||||
| 	local string_byte = string.byte | 	local string_byte = string.byte | ||||||
| 	local string_pack = string.pack | 	local string_pack = string.pack | ||||||
| 
 | 
 | ||||||
| 	function add.i32(a, b) | 	function add.i32(lhs, rhs) | ||||||
| 		return to_u32(a + b) | 		return to_u32(lhs + rhs) | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function sub.i32(a, b) | 	function sub.i32(lhs, rhs) | ||||||
| 		return to_u32(a - b) | 		return to_u32(lhs - rhs) | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function mul.i32(a, b) | 	function mul.i32(lhs, rhs) | ||||||
| 		if (a + b) < BIT_SET_27 then | 		if (lhs + rhs) < BIT_SET_27 then | ||||||
| 			return to_u32(a * b) | 			return to_u32(lhs * rhs) | ||||||
| 		else | 		else | ||||||
| 			local a16 = bit_rshift(a, 16) | 			local a16 = bit_rshift(lhs, 16) | ||||||
| 			local a00 = bit_and(a, 0xFFFF) | 			local a00 = bit_and(lhs, 0xFFFF) | ||||||
| 			local b16 = bit_rshift(b, 16) | 			local b16 = bit_rshift(rhs, 16) | ||||||
| 			local b00 = bit_and(b, 0xFFFF) | 			local b00 = bit_and(rhs, 0xFFFF) | ||||||
| 
 | 
 | ||||||
| 			local c00 = a00 * b00 | 			local c00 = a00 * b00 | ||||||
| 			local c16 = a16 * b00 + a00 * b16 | 			local c16 = a16 * b00 + a00 * b16 | ||||||
| @ -121,19 +121,19 @@ do | |||||||
| 		return -num | 		return -num | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function min.f32(a, b) | 	function min.f32(lhs, rhs) | ||||||
| 		if b == b then | 		if rhs == rhs then | ||||||
| 			return math_min(a, b) | 			return math_min(lhs, rhs) | ||||||
| 		else | 		else | ||||||
| 			return b | 			return rhs | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	function max.f32(a, b) | 	function max.f32(lhs, rhs) | ||||||
| 		if b == b then | 		if rhs == rhs then | ||||||
| 			return math_max(a, b) | 			return math_max(lhs, rhs) | ||||||
| 		else | 		else | ||||||
| 			return b | 			return rhs | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| @ -372,6 +372,9 @@ do | |||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
|  | 	trunc.u64_f32 = num_from_u64 | ||||||
|  | 	trunc.u64_f64 = num_from_u64 | ||||||
|  | 
 | ||||||
| 	function trunc.f32(num) | 	function trunc.f32(num) | ||||||
| 		if num >= 0 then | 		if num >= 0 then | ||||||
| 			return math_floor(num) | 			return math_floor(num) | ||||||
| @ -381,8 +384,6 @@ do | |||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	trunc.f64 = trunc.f32 | 	trunc.f64 = trunc.f32 | ||||||
| 	trunc.u64_f32 = num_from_u64 |  | ||||||
| 	trunc.u64_f64 = num_from_u64 |  | ||||||
| 
 | 
 | ||||||
| 	function extend.i64_i32(num) | 	function extend.i64_i32(num) | ||||||
| 		if num > MAX_SIGNED then | 		if num > MAX_SIGNED then | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user