Lichen

lib/native.py

283:70939defa51d
2016-11-30 Paul Boddie Added dict support, changing the literal instantiators to use functions appropriate for sequences or mappings that set the __data__ attribute on each new instance. Added a __hash__ method for integers.
     1 #!/usr/bin/env python     2      3 """     4 Native library functions. None of these are actually defined here. Instead,     5 native implementations are substituted when each program is built.     6      7 Copyright (C) 2011, 2015, 2016 Paul Boddie <paul@boddie.org.uk>     8      9 This program is free software; you can redistribute it and/or modify it under    10 the terms of the GNU General Public License as published by the Free Software    11 Foundation; either version 3 of the License, or (at your option) any later    12 version.    13     14 This program is distributed in the hope that it will be useful, but WITHOUT    15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    16 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more    17 details.    18     19 You should have received a copy of the GNU General Public License along with    20 this program.  If not, see <http://www.gnu.org/licenses/>.    21 """    22     23 # Environment support.    24     25 def _exit(status): pass    26 def _get_argv(): pass    27 def _get_path(): pass    28     29 # Identity testing.    30     31 def _is(x, y): pass    32 def _is_not(x, y): pass    33     34 # Integer operations.    35     36 def _int_add(self, other): pass    37 def _int_div(self, other): pass    38 def _int_mod(self, other): pass    39 def _int_mul(self, other): pass    40 def _int_neg(self): pass    41 def _int_pow(self, other): pass    42 def _int_sub(self, other): pass    43     44 def _int_and(self, other): pass    45 def _int_or(self, other): pass    46 def _int_xor(self, other): pass    47     48 def _int_lt(self, other): pass    49 def _int_gt(self, other): pass    50 def _int_eq(self, other): pass    51 def _int_ne(self, other): pass    52     53 def _int_str(self): pass    54     55 # String operations.    56     57 def _str_add(self, other): pass    58 def _str_lt(self, other): pass    59 def _str_gt(self, other): pass    60 def _str_eq(self, other): pass    61 def _str_len(self): pass    62 def _str_nonempty(self): pass    63     64 # List operations.    65     66 def _list_init(size): pass    67 def _list_setsize(self, size): pass    68 def _list_append(self, value): pass    69 def _list_concat(self, other): pass    70 def _list_len(self): pass    71 def _list_nonempty(self): pass    72 def _list_element(self, index): pass    73 def _list_setelement(self, index, value): pass    74     75 # Dictionary operations.    76     77 def _dict_init(size): pass    78 def _dict_bucketsize(self, index): pass    79 def _dict_key(self, index, element): pass    80 def _dict_value(self, index, element): pass    81 def _dict_additem(self, index, key, value): pass    82 def _dict_setitem(self, index, element, key, value): pass    83 def _dict_keys(self): pass    84 def _dict_values(self): pass    85     86 # Buffer operations.    87     88 def _buffer_str(self): pass    89     90 # Method binding.    91     92 def _get_using(callable, instance): pass    93     94 # Introspection.    95     96 def _object_getattr(obj, name, default): pass    97 def _isinstance(obj, cls): pass    98 def _issubclass(obj, cls): pass    99    100 # Input/output.   101    102 def _read(fd, n): pass   103 def _write(fd, str): pass   104    105 # vim: tabstop=4 expandtab shiftwidth=4