return intrinsics;
}
-void intrin_intrinsics_destroy() {
- util_htdel(intrin_intrinsics());
-}
-
#define INTRIN_VAL(VALUE, NAME, FUNC, STYPE, VTYPE) \
do { \
(VALUE) = ast_value_new ( \
* local *= x;
* }
* return local;
- * }
+ * }
*/
static ast_value *value = NULL;
* float mod(float x, float y) {
* return x - y * floor(x / y);
* }
- */
+ */
static ast_value *value = NULL;
if (!value) {
* local = x;
*
* return (x != local);
- * }
- */
+ * }
+ */
static ast_value *value = NULL;
if (!value) {
ast_value *local = ast_value_new (parser_ctx(parser), "local", TYPE_FLOAT);
ast_block *body = ast_block_new (parser_ctx(parser));
ast_function *func = NULL;
-
+
INTRIN_VAL(value, "isnan", func, "<float>", TYPE_FLOAT);
vec_push(body->locals, local);
{&intrin_isnan, "__builtin_isnan", "isnan"}
};
+void intrin_intrinsics_destroy(parser_t *parser) {
+ /*size_t i;*/
+ (void)parser;
+ util_htdel(intrin_intrinsics());
+#if 0
+ for (i = 0; i < sizeof(intrinsics)/sizeof(intrin_t); i++)
+ ast_value_delete( (ast_value*) intrinsics[i].intrin(parser));
+#endif
+}
+
+
ast_expression *intrin_func(parser_t *parser, const char *name) {
static bool init = false;
size_t i = 0;
/*
* jesus fucking christ, Blub design something less fucking
* impossible to use, like a ast_is_builtin(ast_expression *), also
- * use a hashtable :P
- */
+ * use a hashtable :P
+ */
if ((find = (void*)parser_find_global(parser, name)) && ((ast_value*)find)->expression.vtype == TYPE_FUNCTION)
for (i = 0; i < vec_size(parser->functions); ++i)
if (((ast_value*)find)->name && !strcmp(parser->functions[i]->name, ((ast_value*)find)->name) && parser->functions[i]->builtin < 0)
- return find;
+ return (ast_expression*)find;
if ((find = util_htget(intrin_intrinsics(), name))) {
/* intrinsic is in table. This will "generate the function" so
* to speak (if it's not already generated).
- */
+ */
return ((intrin_t*)find)->intrin(parser);
}