Basic CTCE working! In between commit because #link(a) syntax changed to #link(a)

This commit is contained in:
Nathan Braswell
2016-07-03 22:50:42 -07:00
parent 6fee942756
commit 0f2ac1421a
17 changed files with 183 additions and 183 deletions

30
stdlib/ctce_lower.krak Normal file
View File

@@ -0,0 +1,30 @@
import symbol:*
import tree:*
import vector:*
import map:*
import util:*
import string:*
import mem:*
import io:*
import ast_nodes:*
import ast_transformation:*
import interpreter:*
import pass_common:*
fun ctce_lower(name_ast_map: *map<string, pair<*tree<symbol>,*ast_node>>, ast_to_syntax: *map<*ast_node, *tree<symbol>>) {
name_ast_map->for_each(fun(name: string, syntax_ast_pair: pair<*tree<symbol>,*ast_node>) {
var helper_before = fun(node: *ast_node, parent_chain: *stack<*ast_node>) {
match(*node) {
ast_node::compiler_intrinsic(backing) {
if (backing.intrinsic == "ctce") {
var result = evaluate_constant_expression(backing.parameters[0])
*node = *unwrap_value(result)
}
}
}
}
run_on_tree(helper_before, empty_pass_second_half, syntax_ast_pair.second)
})
}