2016-06-14 02:14:25 -07:00
|
|
|
import symbol:*
|
|
|
|
|
import tree:*
|
2018-05-22 19:43:54 -04:00
|
|
|
import vec:*
|
2016-06-14 02:14:25 -07:00
|
|
|
import map:*
|
|
|
|
|
import util:*
|
2018-05-22 19:43:54 -04:00
|
|
|
import str:*
|
2016-06-14 02:14:25 -07:00
|
|
|
import mem:*
|
|
|
|
|
import io:*
|
|
|
|
|
import ast_nodes:*
|
|
|
|
|
import ast_transformation:*
|
|
|
|
|
|
2016-06-15 01:36:59 -07:00
|
|
|
import pass_common:*
|
|
|
|
|
|
2018-05-22 19:43:54 -04:00
|
|
|
fun get_line(node: *tree<symbol>, name: str): *ast_node {
|
2018-05-22 20:14:15 -04:00
|
|
|
var to_ret = _passthrough()
|
2018-05-22 19:43:54 -04:00
|
|
|
to_ret->simple_passthrough.passthrough_str = str("\n#line ") + get_first_terminal(node)->data.position + " \"" + name + "\"\n"
|
2016-06-14 02:14:25 -07:00
|
|
|
return to_ret
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 19:43:54 -04:00
|
|
|
fun c_line_control(name_ast_map: *map<str, pair<*tree<symbol>,*ast_node>>, ast_to_syntax: *map<*ast_node, *tree<symbol>>) {
|
2016-06-14 02:14:25 -07:00
|
|
|
var first = true
|
2018-05-22 19:43:54 -04:00
|
|
|
name_ast_map->for_each(fun(name: str, syntax_ast_pair: pair<*tree<symbol>,*ast_node>) {
|
2016-07-03 22:50:42 -07:00
|
|
|
/*var helper = fun(node: *ast_node, parent_chain: *stack<*ast_node>) {*/
|
|
|
|
|
/*match(*node) {*/
|
|
|
|
|
/*if (is_code_block(parent_chain->top()) && ast_to_syntax->contains_key(node)) {*/
|
2018-05-22 19:43:54 -04:00
|
|
|
/*println(str("adding ") + get_ast_name(node) + " to " + get_ast_name(parent))*/
|
2016-07-03 22:50:42 -07:00
|
|
|
/*add_before_in(get_line(ast_to_syntax->get(node), name), node, parent_chain->top())*/
|
|
|
|
|
/*}*/
|
|
|
|
|
/*}*/
|
|
|
|
|
/*}*/
|
|
|
|
|
/*if (first)*/
|
2017-06-12 23:52:12 -04:00
|
|
|
/*run_on_tree(helper, empty_pass_second_half(), syntax_ast_pair.second)*/
|
2016-06-14 02:14:25 -07:00
|
|
|
first = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|