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