implement t, the last simple type
This commit is contained in:
		
							
								
								
									
										24
									
								
								splubp.p8
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								splubp.p8
									
									
									
									
									
								
							| @@ -138,7 +138,9 @@ function splubp:wnx(...) | |||||||
| end | end | ||||||
|  |  | ||||||
| function splubp:emit_item(obj, filename) | function splubp:emit_item(obj, filename) | ||||||
|  debug_last_emit = obj -- global debug |  if DEBUG then | ||||||
|  |   --[[global]] splubp_last_emit = obj | ||||||
|  |  end | ||||||
|  filename = filename or obj._file |  filename = filename or obj._file | ||||||
|  obj._addr = self.ptr |  obj._addr = self.ptr | ||||||
|  self:write_s(filename) |  self:write_s(filename) | ||||||
| @@ -196,6 +198,7 @@ function splubp:write_shr(n) | |||||||
| end | end | ||||||
|  |  | ||||||
| function splubp:write_a(tbl) | function splubp:write_a(tbl) | ||||||
|  |  if (DEBUG) assert(#tbl <= 255, "'a' can't write array of length "..#tbl) | ||||||
|  self:write_c(#tbl) |  self:write_c(#tbl) | ||||||
|  local rpt = self.cri |  local rpt = self.cri | ||||||
|  for item in all(tbl) do |  for item in all(tbl) do | ||||||
| @@ -203,6 +206,17 @@ function splubp:write_a(tbl) | |||||||
|   self:wnx(item) |   self:wnx(item) | ||||||
|  end |  end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | function splubp:write_t(tbl) | ||||||
|  |  if DEBUG then | ||||||
|  |   local want_len = self.row[self.cri] | ||||||
|  |   assert(#tbl == want_len, "'t' wants "..tostr(want_len).." items, but got "..#tbl..": "..tostr(tbl)) | ||||||
|  |  end | ||||||
|  |  for i=1,self:op() do | ||||||
|  |   self:wnx(tbl[i]) | ||||||
|  |  end | ||||||
|  | end | ||||||
|  |  | ||||||
| -->8 | -->8 | ||||||
| -- loader | -- loader | ||||||
|  |  | ||||||
| @@ -234,3 +248,11 @@ function splubp:a() | |||||||
|  end |  end | ||||||
|  return ret |  return ret | ||||||
| end | end | ||||||
|  |  | ||||||
|  | function splubp:t() | ||||||
|  |  local ret = {} | ||||||
|  |  for i=1,self:op() do | ||||||
|  |   add(ret, self:rnx()) | ||||||
|  |  end | ||||||
|  |  return ret | ||||||
|  | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user