paul@261 | 1 | #!/usr/bin/env python |
paul@261 | 2 | |
paul@261 | 3 | """ |
paul@261 | 4 | A native function library for a really simple virtual processor. |
paul@261 | 5 | |
paul@354 | 6 | Copyright (C) 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk> |
paul@261 | 7 | |
paul@261 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@261 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@261 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@261 | 11 | version. |
paul@261 | 12 | |
paul@261 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@261 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@261 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@261 | 16 | details. |
paul@261 | 17 | |
paul@261 | 18 | You should have received a copy of the GNU General Public License along with |
paul@261 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@261 | 20 | """ |
paul@261 | 21 | |
paul@264 | 22 | from micropython.program import DataValue |
paul@261 | 23 | import operator |
paul@261 | 24 | |
paul@261 | 25 | class Library: |
paul@261 | 26 | |
paul@261 | 27 | "Native function implementations." |
paul@261 | 28 | |
paul@354 | 29 | def __init__(self, machine, constants): |
paul@261 | 30 | |
paul@261 | 31 | """ |
paul@354 | 32 | Initialise the library with the 'machine' and the 'constants' addresses |
paul@354 | 33 | dictionary. |
paul@261 | 34 | """ |
paul@261 | 35 | |
paul@261 | 36 | self.machine = machine |
paul@354 | 37 | self.constants = constants |
paul@261 | 38 | |
paul@261 | 39 | # Native class constants. |
paul@261 | 40 | |
paul@261 | 41 | cls = self.machine._get_class("__builtins__", "int") |
paul@261 | 42 | self.int_class = cls.location |
paul@261 | 43 | self.int_instance = cls.instance_template_location |
paul@261 | 44 | cls = self.machine._get_class("__builtins__", "list") |
paul@346 | 45 | if cls is not None: |
paul@346 | 46 | self.list_class = cls.location |
paul@346 | 47 | self.list_instance = cls.instance_template_location |
paul@261 | 48 | cls = self.machine._get_class("__builtins__", "IndexError") |
paul@346 | 49 | if cls is not None: |
paul@346 | 50 | self.index_error = cls.location |
paul@346 | 51 | self.index_error_instance = cls.instance_template_location |
paul@262 | 52 | cls = self.machine._get_class("__builtins__", "basestring") |
paul@346 | 53 | if cls is not None: |
paul@346 | 54 | self.str_class = cls.location |
paul@346 | 55 | self.str_instance = cls.instance_template_location |
paul@261 | 56 | |
paul@261 | 57 | self.tuple_class = self.machine.tuple_class |
paul@261 | 58 | self.type_error_instance = self.machine.type_error_instance |
paul@261 | 59 | |
paul@261 | 60 | self.frame_stack = self.machine.frame_stack |
paul@261 | 61 | self.local_sp_stack = self.machine.local_sp_stack |
paul@261 | 62 | |
paul@390 | 63 | def _get_absolute_index(self, pos, nelements): |
paul@390 | 64 | if pos >= 0 and pos < nelements: |
paul@390 | 65 | return pos |
paul@390 | 66 | elif pos < 0 and pos >= -nelements: |
paul@390 | 67 | return nelements + pos |
paul@390 | 68 | else: |
paul@390 | 69 | return None |
paul@390 | 70 | |
paul@261 | 71 | def builtins_int_arithmetic_op(self, op): |
paul@261 | 72 | frame = self.local_sp_stack[-1] |
paul@261 | 73 | |
paul@261 | 74 | # Get operands addresses. |
paul@261 | 75 | |
paul@264 | 76 | left_value = self.frame_stack[frame] |
paul@264 | 77 | right_value = self.frame_stack[frame + 1] |
paul@261 | 78 | |
paul@261 | 79 | # Test operand suitability. |
paul@261 | 80 | # NOTE: Support other types. |
paul@261 | 81 | |
paul@264 | 82 | if not (self.machine._CheckInstance(left_value.ref, self.int_class) and |
paul@264 | 83 | self.machine._CheckInstance(right_value.ref, self.int_class)): |
paul@264 | 84 | |
paul@261 | 85 | self.machine.exception = self.machine._MakeObject(2, self.type_error_instance) |
paul@261 | 86 | return self.machine.RaiseException() |
paul@261 | 87 | |
paul@261 | 88 | # NOTE: Assume single location for data. |
paul@261 | 89 | |
paul@264 | 90 | left_data = left_value.ref + 1 |
paul@264 | 91 | right_data = right_value.ref + 1 |
paul@261 | 92 | |
paul@261 | 93 | # Make a new object. |
paul@261 | 94 | |
paul@261 | 95 | addr = self.machine._MakeObject(2, self.int_instance) |
paul@261 | 96 | |
paul@261 | 97 | # Store the result. |
paul@261 | 98 | # NOTE: The data is considered ready to use. |
paul@261 | 99 | |
paul@261 | 100 | self.machine.save(addr + 1, op(self.machine.load(left_data), self.machine.load(right_data))) |
paul@261 | 101 | |
paul@261 | 102 | # Return the new object. |
paul@261 | 103 | # Introduce object as context for the new object. |
paul@261 | 104 | |
paul@264 | 105 | self.machine.result = DataValue(addr, addr) |
paul@261 | 106 | |
paul@354 | 107 | def builtins_logical_op(self, operand_class, op): |
paul@262 | 108 | frame = self.local_sp_stack[-1] |
paul@262 | 109 | |
paul@262 | 110 | # Get operands addresses. |
paul@262 | 111 | |
paul@264 | 112 | left_value = self.frame_stack[frame] |
paul@264 | 113 | right_value = self.frame_stack[frame + 1] |
paul@262 | 114 | |
paul@262 | 115 | # Test operand suitability. |
paul@262 | 116 | # NOTE: Handle comparisons of incompatible types more appropriately. |
paul@354 | 117 | # NOTE: Return NotImplemented. |
paul@262 | 118 | |
paul@264 | 119 | if not (self.machine._CheckInstance(left_value.ref, operand_class) and |
paul@264 | 120 | self.machine._CheckInstance(right_value.ref, operand_class)): |
paul@264 | 121 | |
paul@354 | 122 | notimpl = self.constants[NotImplemented] |
paul@354 | 123 | self.machine.result = DataValue(notimpl, notimpl) |
paul@262 | 124 | return |
paul@262 | 125 | |
paul@262 | 126 | # NOTE: Assume single location for data. |
paul@262 | 127 | |
paul@264 | 128 | left_data = left_value.ref + 1 |
paul@264 | 129 | right_data = right_value.ref + 1 |
paul@262 | 130 | |
paul@262 | 131 | # Test the data. |
paul@262 | 132 | # NOTE: The data is considered ready to use. |
paul@262 | 133 | |
paul@262 | 134 | if op(self.machine.load(left_data), self.machine.load(right_data)): |
paul@354 | 135 | self.machine.result = DataValue(self.constants[True], self.constants[True]) |
paul@262 | 136 | else: |
paul@354 | 137 | self.machine.result = DataValue(self.constants[False], self.constants[False]) |
paul@262 | 138 | |
paul@262 | 139 | # Operators. |
paul@262 | 140 | # Although this takes a short-cut by using the operator module, testing is |
paul@262 | 141 | # still performed on the operands to ensure that they qualify for these |
paul@262 | 142 | # native operations. |
paul@262 | 143 | |
paul@262 | 144 | def builtins_int_add(self): |
paul@262 | 145 | return self.builtins_int_arithmetic_op(operator.add) |
paul@262 | 146 | |
paul@262 | 147 | def builtins_int_sub(self): |
paul@262 | 148 | return self.builtins_int_arithmetic_op(operator.sub) |
paul@262 | 149 | |
paul@262 | 150 | def builtins_int_pow(self): |
paul@262 | 151 | return self.builtins_int_arithmetic_op(operator.pow) |
paul@262 | 152 | |
paul@262 | 153 | def builtins_int_lt(self): |
paul@354 | 154 | return self.builtins_logical_op(self.int_class, operator.lt) |
paul@262 | 155 | |
paul@262 | 156 | def builtins_int_le(self): |
paul@354 | 157 | return self.builtins_logical_op(self.int_class, operator.le) |
paul@262 | 158 | |
paul@262 | 159 | def builtins_int_gt(self): |
paul@354 | 160 | return self.builtins_logical_op(self.int_class, operator.gt) |
paul@262 | 161 | |
paul@262 | 162 | def builtins_int_ge(self): |
paul@354 | 163 | return self.builtins_logical_op(self.int_class, operator.ge) |
paul@262 | 164 | |
paul@262 | 165 | def builtins_int_eq(self): |
paul@354 | 166 | return self.builtins_logical_op(self.int_class, operator.eq) |
paul@262 | 167 | |
paul@262 | 168 | def builtins_int_ne(self): |
paul@354 | 169 | return self.builtins_logical_op(self.int_class, operator.ne) |
paul@262 | 170 | |
paul@262 | 171 | def builtins_str_lt(self): |
paul@354 | 172 | return self.builtins_logical_op(self.str_class, operator.lt) |
paul@262 | 173 | |
paul@262 | 174 | def builtins_str_le(self): |
paul@354 | 175 | return self.builtins_logical_op(self.str_class, operator.le) |
paul@262 | 176 | |
paul@262 | 177 | def builtins_str_gt(self): |
paul@354 | 178 | return self.builtins_logical_op(self.str_class, operator.gt) |
paul@262 | 179 | |
paul@262 | 180 | def builtins_str_ge(self): |
paul@354 | 181 | return self.builtins_logical_op(self.str_class, operator.ge) |
paul@262 | 182 | |
paul@262 | 183 | def builtins_str_eq(self): |
paul@354 | 184 | return self.builtins_logical_op(self.str_class, operator.eq) |
paul@262 | 185 | |
paul@262 | 186 | def builtins_str_ne(self): |
paul@354 | 187 | return self.builtins_logical_op(self.str_class, operator.ne) |
paul@262 | 188 | |
paul@262 | 189 | def builtins_int_and(self): |
paul@262 | 190 | return self.builtins_int_arithmetic_op(operator.and_) |
paul@262 | 191 | |
paul@262 | 192 | def builtins_int_or(self): |
paul@262 | 193 | return self.builtins_int_arithmetic_op(operator.or_) |
paul@262 | 194 | |
paul@262 | 195 | # Specific operator methods. |
paul@262 | 196 | |
paul@261 | 197 | def builtins_int_bool(self): |
paul@261 | 198 | frame = self.local_sp_stack[-1] |
paul@261 | 199 | |
paul@261 | 200 | # Get operands addresses. |
paul@261 | 201 | |
paul@264 | 202 | left_value = self.frame_stack[frame] |
paul@261 | 203 | |
paul@261 | 204 | # Test operand suitability. |
paul@261 | 205 | |
paul@264 | 206 | if not self.machine._CheckInstance(left_value.ref, self.int_class): |
paul@261 | 207 | self.machine.exception = self.machine._MakeObject(2, self.type_error_instance) |
paul@261 | 208 | return self.machine.RaiseException() |
paul@261 | 209 | |
paul@261 | 210 | # NOTE: Assume single location for data. |
paul@261 | 211 | |
paul@264 | 212 | left_data = left_value.ref + 1 |
paul@261 | 213 | |
paul@261 | 214 | # Test the data. |
paul@261 | 215 | # NOTE: The data is considered ready to use. |
paul@261 | 216 | |
paul@261 | 217 | if self.machine.load(left_data) != 0: |
paul@354 | 218 | self.machine.result = DataValue(self.constants[True], self.constants[True]) |
paul@261 | 219 | else: |
paul@354 | 220 | self.machine.result = DataValue(self.constants[False], self.constants[False]) |
paul@261 | 221 | |
paul@261 | 222 | def builtins_int_neg(self): |
paul@261 | 223 | frame = self.local_sp_stack[-1] |
paul@261 | 224 | |
paul@261 | 225 | # Get operands addresses. |
paul@261 | 226 | |
paul@264 | 227 | left_value = self.frame_stack[frame] |
paul@261 | 228 | |
paul@261 | 229 | # Test operand suitability. |
paul@261 | 230 | |
paul@264 | 231 | if not self.machine._CheckInstance(left_value.ref, self.int_class): |
paul@261 | 232 | self.machine.exception = self.machine._MakeObject(2, self.type_error_instance) |
paul@261 | 233 | return self.machine.RaiseException() |
paul@261 | 234 | |
paul@261 | 235 | # NOTE: Assume single location for data. |
paul@261 | 236 | |
paul@264 | 237 | left_data = left_value.ref + 1 |
paul@261 | 238 | |
paul@261 | 239 | # Make a new object. |
paul@261 | 240 | |
paul@261 | 241 | addr = self.machine._MakeObject(2, self.int_instance) |
paul@261 | 242 | |
paul@261 | 243 | # Store the result. |
paul@261 | 244 | # NOTE: The data is considered ready to use. |
paul@261 | 245 | |
paul@261 | 246 | self.machine.save(addr + 1, -self.machine.load(left_data)) |
paul@261 | 247 | |
paul@261 | 248 | # Return the new object. |
paul@261 | 249 | # Introduce object as context for the new object. |
paul@261 | 250 | |
paul@264 | 251 | self.machine.result = DataValue(addr, addr) |
paul@261 | 252 | |
paul@262 | 253 | # Various built-in methods. |
paul@261 | 254 | |
paul@261 | 255 | def builtins_bool_bool(self): |
paul@261 | 256 | frame = self.local_sp_stack[-1] |
paul@261 | 257 | |
paul@261 | 258 | # Get operands addresses. |
paul@261 | 259 | |
paul@264 | 260 | left_value = self.frame_stack[frame] |
paul@264 | 261 | self.machine.result = DataValue(left_value.ref, left_value.ref) |
paul@261 | 262 | |
paul@261 | 263 | def builtins_list_new(self): |
paul@261 | 264 | frame = self.local_sp_stack[-1] |
paul@261 | 265 | |
paul@332 | 266 | # The first parameter should be the instance. |
paul@261 | 267 | |
paul@332 | 268 | list_value = self.frame_stack[frame] |
paul@261 | 269 | |
paul@332 | 270 | # Make a new sequence. |
paul@332 | 271 | # NOTE: Using an arbitrary size. |
paul@261 | 272 | |
paul@336 | 273 | new_fragment = self.machine._MakeFragment(1, 5) # include the header |
paul@261 | 274 | |
paul@332 | 275 | # Complete the list instance by saving the fragment reference. |
paul@336 | 276 | # NOTE: This requires an attribute in the list structure. |
paul@261 | 277 | |
paul@332 | 278 | addr = list_value.ref + 1 |
paul@332 | 279 | self.machine.save(addr, DataValue(None, new_fragment)) |
paul@261 | 280 | |
paul@390 | 281 | def builtins_list_get_single_item(self): |
paul@261 | 282 | frame = self.local_sp_stack[-1] |
paul@261 | 283 | |
paul@261 | 284 | # Get the operand address. |
paul@261 | 285 | |
paul@264 | 286 | item_value = self.frame_stack[frame + 1] |
paul@261 | 287 | |
paul@261 | 288 | # Get the list address. |
paul@261 | 289 | |
paul@264 | 290 | obj_value = self.frame_stack[frame] |
paul@261 | 291 | |
paul@261 | 292 | # Get the fragment address. |
paul@261 | 293 | # NOTE: Assume single location for header. |
paul@261 | 294 | |
paul@264 | 295 | fragment = self.machine.load(obj_value.ref + 1) |
paul@261 | 296 | |
paul@261 | 297 | # Get the fragment header. |
paul@261 | 298 | |
paul@264 | 299 | header = self.machine.load(fragment.ref) |
paul@261 | 300 | nelements = header.occupied_size - 1 |
paul@261 | 301 | |
paul@390 | 302 | # NOTE: Assume single location for data and header. |
paul@261 | 303 | |
paul@390 | 304 | item_pos = self.machine.load(item_value.ref + 1) |
paul@261 | 305 | |
paul@390 | 306 | item_pos = self._get_absolute_index(item_pos, nelements) |
paul@372 | 307 | |
paul@390 | 308 | if item_pos is None: |
paul@390 | 309 | self.machine.exception = self.machine._MakeObject(2, self.index_error_instance) |
paul@261 | 310 | return self.machine.RaiseException() |
paul@261 | 311 | |
paul@261 | 312 | # NOTE: Assume single location for header. |
paul@261 | 313 | |
paul@264 | 314 | self.machine.result = self.machine.load(fragment.ref + 1 + item_pos) |
paul@261 | 315 | |
paul@261 | 316 | def builtins_list_len(self): |
paul@261 | 317 | frame = self.local_sp_stack[-1] |
paul@261 | 318 | |
paul@261 | 319 | # Get the list address. |
paul@261 | 320 | |
paul@264 | 321 | obj_value = self.frame_stack[frame] |
paul@261 | 322 | |
paul@261 | 323 | # Get the fragment address. |
paul@261 | 324 | # NOTE: Assume single location for header. |
paul@261 | 325 | |
paul@264 | 326 | fragment = self.machine.load(obj_value.ref + 1) |
paul@261 | 327 | |
paul@261 | 328 | # Get the fragment header. |
paul@261 | 329 | |
paul@264 | 330 | header = self.machine.load(fragment.ref) |
paul@261 | 331 | nelements = header.occupied_size - 1 |
paul@261 | 332 | |
paul@261 | 333 | # Make a new object. |
paul@261 | 334 | |
paul@261 | 335 | addr = self.machine._MakeObject(2, self.int_instance) |
paul@261 | 336 | |
paul@261 | 337 | # Store the result. |
paul@261 | 338 | # NOTE: The data is considered ready to use. |
paul@261 | 339 | |
paul@261 | 340 | self.machine.save(addr + 1, nelements) |
paul@261 | 341 | |
paul@261 | 342 | # Return the new object. |
paul@261 | 343 | # Introduce object as context for the new object. |
paul@261 | 344 | |
paul@264 | 345 | self.machine.result = DataValue(addr, addr) |
paul@261 | 346 | |
paul@261 | 347 | def builtins_list_append(self): |
paul@261 | 348 | frame = self.local_sp_stack[-1] |
paul@261 | 349 | |
paul@261 | 350 | # Get operand address. |
paul@261 | 351 | |
paul@264 | 352 | arg_value = self.frame_stack[frame + 1] |
paul@261 | 353 | |
paul@261 | 354 | # Get the list address. |
paul@261 | 355 | |
paul@264 | 356 | obj_value = self.frame_stack[frame] |
paul@261 | 357 | |
paul@261 | 358 | # Get the fragment address. |
paul@261 | 359 | # NOTE: Assume single location for header. |
paul@261 | 360 | |
paul@264 | 361 | fragment = self.machine.load(obj_value.ref + 1) |
paul@261 | 362 | |
paul@261 | 363 | # Get the fragment header. |
paul@261 | 364 | |
paul@264 | 365 | header = self.machine.load(fragment.ref) |
paul@261 | 366 | |
paul@261 | 367 | # Attempt to add the reference. |
paul@261 | 368 | |
paul@261 | 369 | if header.occupied_size < header.allocated_size: |
paul@264 | 370 | self.machine.save(fragment.ref + header.occupied_size, arg_value) |
paul@261 | 371 | header.occupied_size += 1 |
paul@261 | 372 | else: |
paul@261 | 373 | |
paul@261 | 374 | # Make a new fragment, maintaining more space than currently |
paul@261 | 375 | # occupied in order to avoid reallocation. |
paul@261 | 376 | |
paul@337 | 377 | new_fragment = self.machine._MakeFragment(header.occupied_size + 1, header.occupied_size * 2) |
paul@261 | 378 | |
paul@261 | 379 | # Copy existing elements. |
paul@261 | 380 | |
paul@336 | 381 | for i in range(1, header.occupied_size): |
paul@264 | 382 | self.machine.save(new_fragment + i, self.machine.load(fragment.ref + i)) |
paul@261 | 383 | |
paul@336 | 384 | self.machine.save(new_fragment + header.occupied_size, arg_value) |
paul@261 | 385 | |
paul@261 | 386 | # Set the new fragment in the object. |
paul@261 | 387 | # NOTE: The old fragment could be deallocated. |
paul@261 | 388 | |
paul@264 | 389 | self.machine.save(obj_value.ref + 1, DataValue(None, new_fragment)) |
paul@261 | 390 | |
paul@261 | 391 | def builtins_tuple_len(self): |
paul@261 | 392 | frame = self.local_sp_stack[-1] |
paul@261 | 393 | |
paul@261 | 394 | # Get the tuple address. |
paul@261 | 395 | |
paul@264 | 396 | obj_value = self.frame_stack[frame] |
paul@261 | 397 | |
paul@261 | 398 | # Get the header. |
paul@261 | 399 | # NOTE: Assume single location for header. |
paul@261 | 400 | |
paul@264 | 401 | header = self.machine.load(obj_value.ref) |
paul@261 | 402 | nelements = header.size - 1 |
paul@261 | 403 | |
paul@261 | 404 | # Make a new object. |
paul@261 | 405 | |
paul@261 | 406 | addr = self.machine._MakeObject(2, self.int_instance) |
paul@261 | 407 | |
paul@261 | 408 | # Store the result. |
paul@261 | 409 | # NOTE: The data is considered ready to use. |
paul@261 | 410 | |
paul@261 | 411 | self.machine.save(addr + 1, nelements) |
paul@261 | 412 | |
paul@261 | 413 | # Return the new object. |
paul@261 | 414 | # Introduce object as context for the new object. |
paul@261 | 415 | |
paul@264 | 416 | self.machine.result = DataValue(addr, addr) |
paul@261 | 417 | |
paul@390 | 418 | def builtins_tuple_get_single_item(self): |
paul@261 | 419 | frame = self.local_sp_stack[-1] |
paul@261 | 420 | |
paul@261 | 421 | # Get the operand address. |
paul@261 | 422 | |
paul@264 | 423 | item_value = self.frame_stack[frame + 1] |
paul@261 | 424 | |
paul@261 | 425 | # Get the tuple address. |
paul@261 | 426 | |
paul@264 | 427 | obj_value = self.frame_stack[frame] |
paul@261 | 428 | |
paul@261 | 429 | # Get the header. |
paul@261 | 430 | # NOTE: Assume single location for header. |
paul@261 | 431 | |
paul@264 | 432 | header = self.machine.load(obj_value.ref) |
paul@261 | 433 | nelements = header.size - 1 |
paul@261 | 434 | |
paul@261 | 435 | # NOTE: Assume single location for data and header. |
paul@261 | 436 | |
paul@264 | 437 | item_pos = self.machine.load(item_value.ref + 1) |
paul@261 | 438 | |
paul@390 | 439 | item_pos = self._get_absolute_index(item_pos, nelements) |
paul@390 | 440 | |
paul@390 | 441 | if item_pos is None: |
paul@261 | 442 | self.machine.exception = self.machine._MakeObject(2, self.index_error_instance) |
paul@261 | 443 | return self.machine.RaiseException() |
paul@261 | 444 | |
paul@261 | 445 | # NOTE: Assume single location for header. |
paul@261 | 446 | |
paul@264 | 447 | self.machine.result = self.machine.load(obj_value.ref + 1 + item_pos) |
paul@261 | 448 | |
paul@261 | 449 | def builtins_object_init(self): |
paul@261 | 450 | pass |
paul@261 | 451 | |
paul@377 | 452 | def builtins_isinstance(self): |
paul@377 | 453 | frame = self.local_sp_stack[-1] |
paul@377 | 454 | |
paul@377 | 455 | # Get the operand addresses. |
paul@377 | 456 | |
paul@377 | 457 | obj_value = self.frame_stack[frame] |
paul@377 | 458 | cls_value = self.frame_stack[frame + 1] |
paul@377 | 459 | |
paul@377 | 460 | if self.machine._CheckInstance(obj_value.ref, cls_value.ref): |
paul@377 | 461 | self.machine.result = DataValue(self.constants[True], self.constants[True]) |
paul@377 | 462 | else: |
paul@377 | 463 | self.machine.result = DataValue(self.constants[False], self.constants[False]) |
paul@377 | 464 | |
paul@261 | 465 | native_functions = { |
paul@261 | 466 | |
paul@261 | 467 | # Native method implementations: |
paul@261 | 468 | |
paul@261 | 469 | "__builtins__.int.__add__" : builtins_int_add, |
paul@261 | 470 | "__builtins__.int.__radd__" : builtins_int_add, # NOTE: To be made distinct. |
paul@261 | 471 | "__builtins__.int.__sub__" : builtins_int_sub, |
paul@262 | 472 | "__builtins__.int.__pow__" : builtins_int_pow, |
paul@261 | 473 | "__builtins__.int.__iadd__" : builtins_int_add, |
paul@261 | 474 | "__builtins__.int.__bool__" : builtins_int_bool, |
paul@261 | 475 | "__builtins__.int.__neg__" : builtins_int_neg, |
paul@261 | 476 | "__builtins__.int.__lt__" : builtins_int_lt, |
paul@261 | 477 | "__builtins__.int.__le__" : builtins_int_le, |
paul@261 | 478 | "__builtins__.int.__gt__" : builtins_int_gt, |
paul@261 | 479 | "__builtins__.int.__ge__" : builtins_int_ge, |
paul@261 | 480 | "__builtins__.int.__eq__" : builtins_int_eq, |
paul@261 | 481 | "__builtins__.int.__ne__" : builtins_int_ne, |
paul@261 | 482 | "__builtins__.int.__and__" : builtins_int_and, |
paul@261 | 483 | "__builtins__.int.__rand__" : builtins_int_and, |
paul@261 | 484 | "__builtins__.int.__or__" : builtins_int_or, |
paul@261 | 485 | "__builtins__.int.__ror__" : builtins_int_or, |
paul@261 | 486 | "__builtins__.bool.__bool__" : builtins_bool_bool, |
paul@390 | 487 | "__builtins__.list.__get_single_item__" : builtins_list_get_single_item, |
paul@261 | 488 | "__builtins__.list.__len__" : builtins_list_len, |
paul@261 | 489 | "__builtins__.list.append" : builtins_list_append, |
paul@261 | 490 | "__builtins__.tuple.__len__" : builtins_tuple_len, |
paul@390 | 491 | "__builtins__.tuple.__get_single_item__" : builtins_tuple_get_single_item, |
paul@262 | 492 | "__builtins__.basestring.__lt__" : builtins_str_lt, |
paul@262 | 493 | "__builtins__.basestring.__le__" : builtins_str_le, |
paul@262 | 494 | "__builtins__.basestring.__gt__" : builtins_str_gt, |
paul@262 | 495 | "__builtins__.basestring.__ge__" : builtins_str_ge, |
paul@262 | 496 | "__builtins__.basestring.__eq__" : builtins_str_eq, |
paul@262 | 497 | "__builtins__.basestring.__ne__" : builtins_str_ne, |
paul@261 | 498 | |
paul@261 | 499 | # Native initialisers: |
paul@261 | 500 | |
paul@261 | 501 | "__builtins__.object.__init__" : builtins_object_init, # NOTE: A no-operation. |
paul@261 | 502 | "__builtins__.BaseException.__init__" : builtins_object_init, # NOTE: To be made distinct, potentially in the builtins module. |
paul@261 | 503 | |
paul@332 | 504 | # Native instantiator helpers: |
paul@261 | 505 | |
paul@332 | 506 | "__builtins__.list.__new__" : builtins_list_new, |
paul@377 | 507 | |
paul@377 | 508 | # Native helper functions: |
paul@377 | 509 | |
paul@377 | 510 | "__builtins__._isinstance" : builtins_isinstance, |
paul@261 | 511 | } |
paul@261 | 512 | |
paul@261 | 513 | # vim: tabstop=4 expandtab shiftwidth=4 |