1 #include <stdlib.h> /* calloc, exit */ 2 #include <unistd.h> /* read, write */ 3 #include "types.h" 4 #include "exceptions.h" 5 #include "ops.h" 6 #include "progconsts.h" 7 #include "progops.h" 8 #include "progtypes.h" 9 #include "main.h" 10 11 /* Native functions. */ 12 13 __attr __fn_native__exit(__attr __args[]) 14 { 15 #define status (__args[1]) 16 17 exit(__load_via_object(status.value, __pos___data__).intvalue); 18 return __builtins___none_None; 19 #undef status 20 } 21 22 __attr __fn_native__get_argv(__attr __args[]) 23 { 24 #define status (__args[1]) 25 26 /* NOTE: To be written. */ 27 return __builtins___none_None; 28 #undef status 29 } 30 31 __attr __fn_native__get_path(__attr __args[]) 32 { 33 #define status (__args[1]) 34 35 /* NOTE: To be written. */ 36 return __builtins___none_None; 37 #undef status 38 } 39 40 __attr __fn_native__is(__attr __args[]) 41 { 42 #define x (__args[1]) 43 #define y (__args[2]) 44 45 return x.value == y.value ? __builtins___boolean_True : __builtins___boolean_False; 46 #undef x 47 #undef y 48 } 49 50 __attr __fn_native__is_not(__attr __args[]) 51 { 52 #define x (__args[1]) 53 #define y (__args[2]) 54 55 return x.value != y.value ? __builtins___boolean_True : __builtins___boolean_False; 56 #undef x 57 #undef y 58 } 59 60 __attr __fn_native__int_add(__attr __args[]) 61 { 62 #define self (__args[1]) 63 #define other (__args[2]) 64 65 /* NOTE: To be written. */ 66 return __builtins___none_None; 67 #undef self 68 #undef other 69 } 70 71 __attr __fn_native__int_sub(__attr __args[]) 72 { 73 #define self (__args[1]) 74 #define other (__args[2]) 75 76 /* NOTE: To be written. */ 77 return __builtins___none_None; 78 #undef self 79 #undef other 80 } 81 82 __attr __fn_native__int_mul(__attr __args[]) 83 { 84 #define self (__args[1]) 85 #define other (__args[2]) 86 87 /* NOTE: To be written. */ 88 return __builtins___none_None; 89 #undef self 90 #undef other 91 } 92 93 __attr __fn_native__int_div(__attr __args[]) 94 { 95 #define self (__args[1]) 96 #define other (__args[2]) 97 98 /* NOTE: To be written. */ 99 return __builtins___none_None; 100 #undef self 101 #undef other 102 } 103 104 __attr __fn_native__int_mod(__attr __args[]) 105 { 106 #define self (__args[1]) 107 #define other (__args[2]) 108 109 /* NOTE: To be written. */ 110 return __builtins___none_None; 111 #undef self 112 #undef other 113 } 114 115 __attr __fn_native__int_pow(__attr __args[]) 116 { 117 #define self (__args[1]) 118 #define other (__args[2]) 119 120 /* NOTE: To be written. */ 121 return __builtins___none_None; 122 #undef self 123 #undef other 124 } 125 126 __attr __fn_native__int_and(__attr __args[]) 127 { 128 #define self (__args[1]) 129 #define other (__args[2]) 130 131 /* NOTE: To be written. */ 132 return __builtins___none_None; 133 #undef self 134 #undef other 135 } 136 137 __attr __fn_native__int_or(__attr __args[]) 138 { 139 #define self (__args[1]) 140 #define other (__args[2]) 141 142 /* NOTE: To be written. */ 143 return __builtins___none_None; 144 #undef self 145 #undef other 146 } 147 148 __attr __fn_native__int_xor(__attr __args[]) 149 { 150 #define self (__args[1]) 151 #define other (__args[2]) 152 153 /* NOTE: To be written. */ 154 return __builtins___none_None; 155 #undef self 156 #undef other 157 } 158 159 __attr __fn_native__int_rsub(__attr __args[]) 160 { 161 #define self (__args[1]) 162 #define other (__args[2]) 163 164 /* NOTE: To be written. */ 165 return __builtins___none_None; 166 #undef self 167 #undef other 168 } 169 170 __attr __fn_native__int_rdiv(__attr __args[]) 171 { 172 #define self (__args[1]) 173 #define other (__args[2]) 174 175 /* NOTE: To be written. */ 176 return __builtins___none_None; 177 #undef self 178 #undef other 179 } 180 181 __attr __fn_native__int_rmod(__attr __args[]) 182 { 183 #define self (__args[1]) 184 #define other (__args[2]) 185 186 /* NOTE: To be written. */ 187 return __builtins___none_None; 188 #undef self 189 #undef other 190 } 191 192 __attr __fn_native__int_rpow(__attr __args[]) 193 { 194 #define self (__args[1]) 195 #define other (__args[2]) 196 197 /* NOTE: To be written. */ 198 return __builtins___none_None; 199 #undef self 200 #undef other 201 } 202 203 __attr __fn_native__int_lt(__attr __args[]) 204 { 205 #define self (__args[1]) 206 #define other (__args[2]) 207 208 /* NOTE: To be written. */ 209 return __builtins___none_None; 210 #undef self 211 #undef other 212 } 213 214 __attr __fn_native__int_gt(__attr __args[]) 215 { 216 #define self (__args[1]) 217 #define other (__args[2]) 218 219 /* NOTE: To be written. */ 220 return __builtins___none_None; 221 #undef self 222 #undef other 223 } 224 225 __attr __fn_native__int_eq(__attr __args[]) 226 { 227 #define self (__args[1]) 228 #define other (__args[2]) 229 230 /* NOTE: To be written. */ 231 return __builtins___none_None; 232 #undef self 233 #undef other 234 } 235 236 __attr __fn_native__str_add(__attr __args[]) 237 { 238 #define self (__args[1]) 239 #define other (__args[2]) 240 241 /* NOTE: To be written. */ 242 return __builtins___none_None; 243 #undef self 244 #undef other 245 } 246 247 __attr __fn_native__str_lt(__attr __args[]) 248 { 249 #define self (__args[1]) 250 #define other (__args[2]) 251 252 /* NOTE: To be written. */ 253 return __builtins___none_None; 254 #undef self 255 #undef other 256 } 257 258 __attr __fn_native__str_gt(__attr __args[]) 259 { 260 #define self (__args[1]) 261 #define other (__args[2]) 262 263 /* NOTE: To be written. */ 264 return __builtins___none_None; 265 #undef self 266 #undef other 267 } 268 269 __attr __fn_native__str_eq(__attr __args[]) 270 { 271 #define self (__args[1]) 272 #define other (__args[2]) 273 274 /* NOTE: To be written. */ 275 return __builtins___none_None; 276 #undef self 277 #undef other 278 } 279 280 __attr __fn_native__str_len(__attr __args[]) 281 { 282 #define self (__args[1]) 283 284 /* NOTE: To be written. */ 285 return __builtins___none_None; 286 #undef self 287 } 288 289 __attr __fn_native__str_nonempty(__attr __args[]) 290 { 291 #define self (__args[1]) 292 293 /* NOTE: To be written. */ 294 return __builtins___none_None; 295 #undef self 296 } 297 298 __attr __fn_native__list_init(__attr __args[]) 299 { 300 #define size (__args[1]) 301 /* size.__data__ interpreted as int */ 302 __fragment *data = calloc(__load_via_object(size.value, __pos___data__).intvalue, sizeof(__attr)); 303 __attr attr = {0, .data=data}; 304 305 return attr; 306 #undef size 307 } 308 309 __attr __fn_native__list_len(__attr __args[]) 310 { 311 #define self (__args[1]) 312 /* self.__data__ interpreted as fragment */ 313 unsigned int size = __load_via_object(self.value, __pos___data__).data->size; 314 315 /* Create a new integer and mutate the __data__ attribute. */ 316 __attr length = __new(&__InstanceTable___builtins___int_int, &__builtins___int_int, sizeof(__obj___builtins___int_int)); 317 length.value->attrs[__pos___data__].intvalue = size; 318 319 /* Return the new integer. */ 320 return length; 321 #undef self 322 } 323 324 __attr __fn_native__list_nonempty(__attr __args[]) 325 { 326 #define self (__args[1]) 327 328 return __load_via_object(self.value, __pos___data__).data->size ? __builtins___boolean_True : __builtins___boolean_False; 329 #undef self 330 } 331 332 __attr __fn_native__list_element(__attr __args[]) 333 { 334 #define self (__args[1]) 335 #define index (__args[2]) 336 337 /* NOTE: To be written. */ 338 return __builtins___none_None; 339 #undef self 340 #undef index 341 } 342 343 __attr __fn_native__list_to_tuple(__attr __args[]) 344 { 345 #define l (__args[1]) 346 347 /* NOTE: To be written. */ 348 return __builtins___none_None; 349 #undef l 350 } 351 352 __attr __fn_native__tuple_init(__attr __args[]) 353 { 354 #define size (__args[1]) 355 /* size.__data__ interpreted as int */ 356 __fragment *data = calloc(__load_via_object(size.value, __pos___data__).intvalue, sizeof(__attr)); 357 __attr attr = {0, .data=data}; 358 359 return attr; 360 #undef size 361 } 362 363 __attr __fn_native__tuple_len(__attr __args[]) 364 { 365 #define self (__args[1]) 366 367 /* NOTE: To be written. */ 368 return __builtins___none_None; 369 #undef self 370 } 371 372 __attr __fn_native__tuple_element(__attr __args[]) 373 { 374 #define self (__args[1]) 375 #define index (__args[2]) 376 377 /* NOTE: To be written. */ 378 return __builtins___none_None; 379 #undef self 380 #undef index 381 } 382 383 __attr __fn_native__isinstance(__attr __args[]) 384 { 385 #define obj (__args[1]) 386 #define cls (__args[2]) 387 388 if (__is_instance(obj.value) && __HASATTR(__get_class(obj.value), __TYPEPOS(cls.value), __TYPECODE(cls.value))) 389 return obj; 390 else 391 return __builtins___none_None; 392 #undef obj 393 #undef cls 394 } 395 396 __attr __fn_native__read(__attr __args[]) 397 { 398 #define fd (__args[1]) 399 #define n (__args[2]) 400 401 /* NOTE: To be written. */ 402 return __builtins___none_None; 403 #undef fd 404 #undef n 405 } 406 407 __attr __fn_native__write(__attr __args[]) 408 { 409 #define fd (__args[1]) 410 #define str (__args[2]) 411 412 /* NOTE: To be written. */ 413 return __builtins___none_None; 414 #undef fd 415 #undef str 416 } 417 418 /* Module initialisation. */ 419 420 void __main_native() 421 { 422 }