LLVMValueRef gen_param(compile_t* c, ast_t* ast) { ast_t* def = ast_get(ast, ast_name(ast_child(ast)), NULL); int index = (int)ast_index(def); return LLVMGetParam(codegen_fun(c), index + 1); }
LLVMValueRef gen_param(compile_t* c, ast_t* ast) { ast_t* def = (ast_t*)ast_data(ast); pony_assert(def != NULL); int index = (int)ast_index(def); if(!c->frame->bare_function) index++; return LLVMGetParam(codegen_fun(c), index); }
static LLVMValueRef make_fieldptr(compile_t* c, LLVMValueRef l_value, ast_t* l_type, ast_t* right) { switch(ast_id(l_type)) { case TK_NOMINAL: { assert(ast_id(right) == TK_ID); ast_t* def = (ast_t*)ast_data(l_type); ast_t* field = ast_get(def, ast_name(right), NULL); int index = (int)ast_index(field); if(ast_id(def) != TK_STRUCT) index++; if(ast_id(def) == TK_ACTOR) index++; return LLVMBuildStructGEP(c->builder, l_value, index, ""); } case TK_TUPLETYPE: { assert(ast_id(right) == TK_INT); int index = (int)ast_int(right)->low; return LLVMBuildExtractValue(c->builder, l_value, index, ""); } case TK_ARROW: return make_fieldptr(c, l_value, ast_childidx(l_type, 1), right); default: {} } assert(0); return NULL; }
ast_t* ast_try_clause(ast_t* ast, size_t* clause) { ast_t* last = NULL; while(ast != NULL) { switch(token_get_id(ast->t)) { case TK_TRY: case TK_TRY_NO_CHECK: { *clause = ast_index(last); return ast; } default: {} } last = ast; ast = ast_parent(ast); } return NULL; }