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