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