diff --git a/k.krak b/k.krak index 2705d09..f48f035 100644 --- a/k.krak +++ b/k.krak @@ -131,6 +131,23 @@ fun main(argc: int, argv: **char): int { } } } + // cute hack for getting plain = + math.add(str("")) + for (var i = 0; i < math.size; i++;) { + primitive_ops["op" + math[i] + "="] = vec<*tree>() + for (var j = 0; j < number_tower.size; j++;) { + for (var k = 0; k <= j; k++;) { + var return_type = null>() + primitive_ops["op" + math[i] + "="].add(_compiler_intrinsic(math[i] + "=", binding(type(base_type::_fun(make_triple(make_pair(vec( + number_tower[j], + number_tower[k] + ), + binding(type(base_type::_void(), 0, false)) + ), false, false)), 0, false)), vec<*binding>())) + } + } + } + math.remove(math.size-1) // resolves all binding possibilities for one top level item passes[str("name_possibility_resolve")] = fun(item: *tree) { @@ -253,7 +270,6 @@ fun main(argc: int, argv: **char): int { } error("Trying to get type of call where type of first child is not function, but " + t->bound_to->to_string()) } - /*ast::_compiler_intrinsic(b) return str("_compiler_intrinsic(") + b.first + ")"*/ ast::_cast(b) return b ast::_value(b) return b.second } @@ -283,7 +299,6 @@ fun main(argc: int, argv: **char): int { match (t->data) { ast::_declaration() if (t->children.size > 1) unify(get_type(t->children[0]), get_type(t->children[1])) - /*ast::_assignment() unify(get_type(t->children[0]), get_type(t->children[1]))*/ ast::_call() { // we call get type to make sure if it is unknown it is transformed into a function version get_type(t) @@ -542,7 +557,6 @@ fun main(argc: int, argv: **char): int { C_declaration_str += idt + to_c_type(t->children[0]->data._identifier.second) + " " + get_c_name(t->children[0]) + ";\n" } } - ast::_assignment() { error("assignment gen unimplemented"); } ast::_block() { C_str += idt + "{\n" t->children.for_each(fun(c: *tree) { @@ -805,7 +819,7 @@ fun syntax_to_ast(file_name: str, syntax: *tree, import_paths: ref vecdata.name == "assignment_statement") - return _assignment(vec(make_ast_binding(concat(syntax->children[1])), + return _call(vec(make_ast_binding("op" + concat(syntax->children[1])), syntax_to_ast_helper(syntax->children[0]), syntax_to_ast_helper(syntax->children[2]))) else if (syntax->data.name == "function_call") diff --git a/stdlib/ast.krak b/stdlib/ast.krak index 780a9dd..0d23ff1 100644 --- a/stdlib/ast.krak +++ b/stdlib/ast.krak @@ -16,7 +16,6 @@ adt ast { _function: triple, bool>, _template: pair>, _declaration, - _assignment, _block, _if, _match, @@ -43,7 +42,6 @@ fun to_string(a: ref ast): str { ast::_function(b) return str("_function(") + b.first + ": " + deref_to_string(b.second->bound_to) + ", ext?:" + to_string(b.third) + ")" ast::_template(b) return str("_template(") + b.first + "[" + str(",").join(b.second.data) + "])" ast::_declaration() return str("_declaration") - ast::_assignment() return str("_assignment") ast::_block() return str("_block") ast::_if() return str("_if") ast::_match() return str("_match") @@ -96,9 +94,6 @@ fun _value(p1: str, p2: *binding): *tree { fun _declaration(): *tree { return new>()->construct(ast::_declaration()) } -fun _assignment(): *tree { - return new>()->construct(ast::_assignment()) -} fun _block(): *tree { return new>()->construct(ast::_block()) } @@ -171,9 +166,6 @@ fun _value(p1: str, p2: *binding, c: ref vec<*tree>): *tree { fun _declaration(c: ref vec<*tree>): *tree { return new>()->construct(ast::_declaration(), c) } -fun _assignment(c: ref vec<*tree>): *tree { - return new>()->construct(ast::_assignment(), c) -} fun _block(c: ref vec<*tree>): *tree { return new>()->construct(ast::_block(), c) } @@ -219,7 +211,6 @@ fun is_adt_def(i: *tree): bool { match(i->data) { ast::_adt_def(b) return t fun is_function(i: *tree): bool { match(i->data) { ast::_function(b) return true; } return false; } fun is_template(i: *tree): bool { match(i->data) { ast::_template(b) return true; } return false; } fun is_declaration(i: *tree): bool { match(i->data) { ast::_declaration() return true; } return false; } -fun is_assignment(i: *tree): bool { match(i->data) { ast::_assignment() return true; } return false; } fun is_block(i: *tree): bool { match(i->data) { ast::_block() return true; } return false; } fun is_if(i: *tree): bool { match(i->data) { ast::_if() return true; } return false; } fun is_match(i: *tree): bool { match(i->data) { ast::_match() return true; } return false; }