1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/templates/native.c Mon Oct 31 21:53:38 2016 +0100
1.3 @@ -0,0 +1,363 @@
1.4 +#include <stdlib.h>
1.5 +#include "types.h"
1.6 +#include "exceptions.h"
1.7 +#include "ops.h"
1.8 +#include "progconsts.h"
1.9 +#include "progops.h"
1.10 +#include "progtypes.h"
1.11 +#include "main.h"
1.12 +
1.13 +__attr __fn_native__is(__attr __args[])
1.14 +{
1.15 + #define x (__args[1])
1.16 + #define y (__args[2])
1.17 +
1.18 + return x.value == y.value ? __builtins___boolean_True : __builtins___boolean_False;
1.19 + #undef x
1.20 + #undef y
1.21 +}
1.22 +
1.23 +__attr __fn_native__is_not(__attr __args[])
1.24 +{
1.25 + #define x (__args[1])
1.26 + #define y (__args[2])
1.27 +
1.28 + return x.value != y.value ? __builtins___boolean_True : __builtins___boolean_False;
1.29 + #undef x
1.30 + #undef y
1.31 +}
1.32 +
1.33 +__attr __fn_native__int_add(__attr __args[])
1.34 +{
1.35 + #define self (__args[1])
1.36 + #define other (__args[2])
1.37 +
1.38 + /* NOTE: To be written. */
1.39 + return __builtins___none_None;
1.40 + #undef self
1.41 + #undef other
1.42 +}
1.43 +
1.44 +__attr __fn_native__int_sub(__attr __args[])
1.45 +{
1.46 + #define self (__args[1])
1.47 + #define other (__args[2])
1.48 +
1.49 + /* NOTE: To be written. */
1.50 + return __builtins___none_None;
1.51 + #undef self
1.52 + #undef other
1.53 +}
1.54 +
1.55 +__attr __fn_native__int_mul(__attr __args[])
1.56 +{
1.57 + #define self (__args[1])
1.58 + #define other (__args[2])
1.59 +
1.60 + /* NOTE: To be written. */
1.61 + return __builtins___none_None;
1.62 + #undef self
1.63 + #undef other
1.64 +}
1.65 +
1.66 +__attr __fn_native__int_div(__attr __args[])
1.67 +{
1.68 + #define self (__args[1])
1.69 + #define other (__args[2])
1.70 +
1.71 + /* NOTE: To be written. */
1.72 + return __builtins___none_None;
1.73 + #undef self
1.74 + #undef other
1.75 +}
1.76 +
1.77 +__attr __fn_native__int_mod(__attr __args[])
1.78 +{
1.79 + #define self (__args[1])
1.80 + #define other (__args[2])
1.81 +
1.82 + /* NOTE: To be written. */
1.83 + return __builtins___none_None;
1.84 + #undef self
1.85 + #undef other
1.86 +}
1.87 +
1.88 +__attr __fn_native__int_pow(__attr __args[])
1.89 +{
1.90 + #define self (__args[1])
1.91 + #define other (__args[2])
1.92 +
1.93 + /* NOTE: To be written. */
1.94 + return __builtins___none_None;
1.95 + #undef self
1.96 + #undef other
1.97 +}
1.98 +
1.99 +__attr __fn_native__int_and(__attr __args[])
1.100 +{
1.101 + #define self (__args[1])
1.102 + #define other (__args[2])
1.103 +
1.104 + /* NOTE: To be written. */
1.105 + return __builtins___none_None;
1.106 + #undef self
1.107 + #undef other
1.108 +}
1.109 +
1.110 +__attr __fn_native__int_or(__attr __args[])
1.111 +{
1.112 + #define self (__args[1])
1.113 + #define other (__args[2])
1.114 +
1.115 + /* NOTE: To be written. */
1.116 + return __builtins___none_None;
1.117 + #undef self
1.118 + #undef other
1.119 +}
1.120 +
1.121 +__attr __fn_native__int_xor(__attr __args[])
1.122 +{
1.123 + #define self (__args[1])
1.124 + #define other (__args[2])
1.125 +
1.126 + /* NOTE: To be written. */
1.127 + return __builtins___none_None;
1.128 + #undef self
1.129 + #undef other
1.130 +}
1.131 +
1.132 +__attr __fn_native__int_rsub(__attr __args[])
1.133 +{
1.134 + #define self (__args[1])
1.135 + #define other (__args[2])
1.136 +
1.137 + /* NOTE: To be written. */
1.138 + return __builtins___none_None;
1.139 + #undef self
1.140 + #undef other
1.141 +}
1.142 +
1.143 +__attr __fn_native__int_rdiv(__attr __args[])
1.144 +{
1.145 + #define self (__args[1])
1.146 + #define other (__args[2])
1.147 +
1.148 + /* NOTE: To be written. */
1.149 + return __builtins___none_None;
1.150 + #undef self
1.151 + #undef other
1.152 +}
1.153 +
1.154 +__attr __fn_native__int_rmod(__attr __args[])
1.155 +{
1.156 + #define self (__args[1])
1.157 + #define other (__args[2])
1.158 +
1.159 + /* NOTE: To be written. */
1.160 + return __builtins___none_None;
1.161 + #undef self
1.162 + #undef other
1.163 +}
1.164 +
1.165 +__attr __fn_native__int_rpow(__attr __args[])
1.166 +{
1.167 + #define self (__args[1])
1.168 + #define other (__args[2])
1.169 +
1.170 + /* NOTE: To be written. */
1.171 + return __builtins___none_None;
1.172 + #undef self
1.173 + #undef other
1.174 +}
1.175 +
1.176 +__attr __fn_native__int_lt(__attr __args[])
1.177 +{
1.178 + #define self (__args[1])
1.179 + #define other (__args[2])
1.180 +
1.181 + /* NOTE: To be written. */
1.182 + return __builtins___none_None;
1.183 + #undef self
1.184 + #undef other
1.185 +}
1.186 +
1.187 +__attr __fn_native__int_gt(__attr __args[])
1.188 +{
1.189 + #define self (__args[1])
1.190 + #define other (__args[2])
1.191 +
1.192 + /* NOTE: To be written. */
1.193 + return __builtins___none_None;
1.194 + #undef self
1.195 + #undef other
1.196 +}
1.197 +
1.198 +__attr __fn_native__int_eq(__attr __args[])
1.199 +{
1.200 + #define self (__args[1])
1.201 + #define other (__args[2])
1.202 +
1.203 + /* NOTE: To be written. */
1.204 + return __builtins___none_None;
1.205 + #undef self
1.206 + #undef other
1.207 +}
1.208 +
1.209 +__attr __fn_native__str_add(__attr __args[])
1.210 +{
1.211 + #define self (__args[1])
1.212 + #define other (__args[2])
1.213 +
1.214 + /* NOTE: To be written. */
1.215 + return __builtins___none_None;
1.216 + #undef self
1.217 + #undef other
1.218 +}
1.219 +
1.220 +__attr __fn_native__str_lt(__attr __args[])
1.221 +{
1.222 + #define self (__args[1])
1.223 + #define other (__args[2])
1.224 +
1.225 + /* NOTE: To be written. */
1.226 + return __builtins___none_None;
1.227 + #undef self
1.228 + #undef other
1.229 +}
1.230 +
1.231 +__attr __fn_native__str_gt(__attr __args[])
1.232 +{
1.233 + #define self (__args[1])
1.234 + #define other (__args[2])
1.235 +
1.236 + /* NOTE: To be written. */
1.237 + return __builtins___none_None;
1.238 + #undef self
1.239 + #undef other
1.240 +}
1.241 +
1.242 +__attr __fn_native__str_eq(__attr __args[])
1.243 +{
1.244 + #define self (__args[1])
1.245 + #define other (__args[2])
1.246 +
1.247 + /* NOTE: To be written. */
1.248 + return __builtins___none_None;
1.249 + #undef self
1.250 + #undef other
1.251 +}
1.252 +
1.253 +__attr __fn_native__str_len(__attr __args[])
1.254 +{
1.255 + #define self (__args[1])
1.256 +
1.257 + /* NOTE: To be written. */
1.258 + return __builtins___none_None;
1.259 + #undef self
1.260 +}
1.261 +
1.262 +__attr __fn_native__str_nonempty(__attr __args[])
1.263 +{
1.264 + #define self (__args[1])
1.265 +
1.266 + /* NOTE: To be written. */
1.267 + return __builtins___none_None;
1.268 + #undef self
1.269 +}
1.270 +
1.271 +__attr __fn_native__list_init(__attr __args[])
1.272 +{
1.273 + #define size (__args[1])
1.274 + /* size.__data__ interpreted as int */
1.275 + __fragment *data = calloc(__load_via_object(size.value, __pos___data__).intvalue, sizeof(__attr));
1.276 + __attr attr = {0, .data=data};
1.277 +
1.278 + return attr;
1.279 + #undef size
1.280 +}
1.281 +
1.282 +__attr __fn_native__list_len(__attr __args[])
1.283 +{
1.284 + #define self (__args[1])
1.285 +
1.286 + /* NOTE: To be written. */
1.287 + return __builtins___none_None;
1.288 + #undef self
1.289 +}
1.290 +
1.291 +__attr __fn_native__list_nonempty(__attr __args[])
1.292 +{
1.293 + #define self (__args[1])
1.294 +
1.295 + /* NOTE: To be written. */
1.296 + return __builtins___none_None;
1.297 + #undef self
1.298 +}
1.299 +
1.300 +__attr __fn_native__list_element(__attr __args[])
1.301 +{
1.302 + #define self (__args[1])
1.303 + #define index (__args[2])
1.304 +
1.305 + /* NOTE: To be written. */
1.306 + return __builtins___none_None;
1.307 + #undef self
1.308 + #undef index
1.309 +}
1.310 +
1.311 +__attr __fn_native__list_to_tuple(__attr __args[])
1.312 +{
1.313 + #define l (__args[1])
1.314 +
1.315 + /* NOTE: To be written. */
1.316 + return __builtins___none_None;
1.317 + #undef l
1.318 +}
1.319 +
1.320 +__attr __fn_native__tuple_init(__attr __args[])
1.321 +{
1.322 + #define size (__args[1])
1.323 + /* size.__data__ interpreted as int */
1.324 + __fragment *data = calloc(__load_via_object(size.value, __pos___data__).intvalue, sizeof(__attr));
1.325 + __attr attr = {0, .data=data};
1.326 +
1.327 + return attr;
1.328 + #undef size
1.329 +}
1.330 +
1.331 +__attr __fn_native__tuple_len(__attr __args[])
1.332 +{
1.333 + #define self (__args[1])
1.334 +
1.335 + /* NOTE: To be written. */
1.336 + return __builtins___none_None;
1.337 + #undef self
1.338 +}
1.339 +
1.340 +__attr __fn_native__tuple_element(__attr __args[])
1.341 +{
1.342 + #define self (__args[1])
1.343 + #define index (__args[2])
1.344 +
1.345 + /* NOTE: To be written. */
1.346 + return __builtins___none_None;
1.347 + #undef self
1.348 + #undef index
1.349 +}
1.350 +
1.351 +__attr __fn_native__isinstance(__attr __args[])
1.352 +{
1.353 + #define obj (__args[1])
1.354 + #define cls (__args[2])
1.355 +
1.356 + if (__HASATTR(obj.value, __TYPEPOS(cls.value), __TYPECODE(cls.value)))
1.357 + return obj;
1.358 + else
1.359 + return __builtins___none_None;
1.360 + #undef obj
1.361 + #undef cls
1.362 +}
1.363 +
1.364 +void __main_native()
1.365 +{
1.366 +}