static void gen_estore( const act* action, int column, bool special) { const gpre_req* request = action->act_request; align(column); gen_compile(request, column); gen_start(request, request->req_primary, column, special); }
static void gen_any( qli_nod* node, qli_req* request) { /************************************** * * g e n _ a n y * ************************************** * * Functional description * Generate the BLR for a statistical expresionn. * **************************************/ qli_rlb* rlb; // If there is a request associated with the statement, prepare to // generate BLR. Otherwise assume that a request is alrealdy initialized. qli_req* new_request = (qli_req*) node->nod_arg[e_any_request]; if (new_request) { request = new_request; gen_request(request); const qli_msg* receive = (qli_msg*) node->nod_arg[e_any_send]; if (receive) gen_send_receive(receive, blr_receive); const qli_msg* send = (qli_msg*) node->nod_arg[e_any_receive]; gen_send_receive(send, blr_send); rlb = CHECK_RLB(request->req_blr); STUFF(blr_if); } else rlb = CHECK_RLB(request->req_blr); STUFF(blr_any); gen_rse(node->nod_arg[e_any_rse], request); USHORT value; // not feasible to change it to bool. dsc desc; if (new_request) { desc.dsc_dtype = dtype_short; desc.dsc_length = sizeof(SSHORT); desc.dsc_scale = 0; desc.dsc_sub_type = 0; desc.dsc_address = (UCHAR*) &value; QLI_validate_desc(desc); STUFF(blr_assignment); value = TRUE; gen_literal(&desc, request); gen_parameter(node->nod_import, request); STUFF(blr_assignment); value = FALSE; gen_literal(&desc, request); gen_parameter(node->nod_import, request); gen_compile(request); } }
static void gen_s_start( const act* action, int column) { const gpre_req* request = action->act_request; gen_compile(request, column); const gpre_port* port = request->req_vport; if (port) asgn_from(port->por_references, column); gen_start(request, port, column, false); }
static void gen_store( qli_nod* node, qli_req* request) { /************************************** * * g e n _ s t o r e * ************************************** * * Functional description * Generate code for STORE statement. * **************************************/ // If there is a request associated with the statement, prepare to // generate BLR. Otherwise assume that a request is alrealdy initialized. if (node->nod_arg[e_sto_request]) { request = (qli_req*) node->nod_arg[e_sto_request]; gen_request(request); } qli_rlb* rlb = CHECK_RLB(request->req_blr); // If there is a message to be sent, build a receive for it if (node->nod_arg[e_sto_send]) gen_send_receive((qli_msg*) node->nod_arg[e_sto_send], blr_receive); // Generate the STORE statement proper. STUFF(blr_store); qli_ctx* context = (qli_ctx*) node->nod_arg[e_sto_context]; qli_rel* relation = context->ctx_relation; STUFF(blr_rid); STUFF_WORD(relation->rel_id); STUFF(context->ctx_context); // Build the body of the loop. STUFF(blr_begin); gen_statement(node->nod_arg[e_sto_statement], request); STUFF(blr_end); // If this is our request, compile it. if (node->nod_arg[e_sto_request]) gen_compile(request); }
static void gen_statistical( qli_nod* node, qli_req* request) { /************************************** * * g e n _ s t a t i s t i c a l * ************************************** * * Functional description * Generate the BLR for a statistical expresionn. * **************************************/ USHORT operatr; switch (node->nod_type) { case nod_average: operatr = blr_average; break; case nod_count: // count2 // operatr = node->nod_arg [e_stt_value] ? blr_count2 : blr_count; operatr = blr_count; break; case nod_max: operatr = blr_maximum; break; case nod_min: operatr = blr_minimum; break; case nod_total: operatr = blr_total; break; case nod_agg_average: operatr = blr_agg_average; break; case nod_agg_count: // count2 // operatr = node->nod_arg [e_stt_value] ? blr_agg_count2 : blr_agg_count; operatr = blr_agg_count; break; case nod_agg_max: operatr = blr_agg_max; break; case nod_agg_min: operatr = blr_agg_min; break; case nod_agg_total: operatr = blr_agg_total; break; case nod_from: operatr = node->nod_arg[e_stt_default] ? blr_via : blr_from; break; default: ERRQ_bugcheck(355); // Msg355 gen_statistical: not understood } // If there is a request associated with the statement, prepare to // generate BLR. Otherwise assume that a request is alrealdy initialized. qli_rlb* rlb; qli_req* new_request = (qli_req*) node->nod_arg[e_stt_request]; if (new_request) { request = new_request; gen_request(request); const qli_msg* receive = (qli_msg*) node->nod_arg[e_stt_send]; if (receive) gen_send_receive(receive, blr_receive); const qli_msg* send = (qli_msg*) node->nod_arg[e_stt_receive]; gen_send_receive(send, blr_send); rlb = CHECK_RLB(request->req_blr); STUFF(blr_assignment); } else rlb = CHECK_RLB(request->req_blr); STUFF(operatr); if (node->nod_arg[e_stt_rse]) gen_rse(node->nod_arg[e_stt_rse], request); // count 2 // if (node->nod_arg [e_stt_value]) if (node->nod_arg[e_stt_value] && node->nod_type != nod_agg_count) gen_expression(node->nod_arg[e_stt_value], request); if (node->nod_arg[e_stt_default]) gen_expression(node->nod_arg[e_stt_default], request); if (new_request) { gen_parameter(node->nod_import, request); gen_compile(request); } }
static void gen_function( qli_nod* node, qli_req* request) { /************************************** * * g e n _ f u n c t i o n * ************************************** * * Functional description * Generate blr for a function reference. * **************************************/ qli_req* new_request; qli_rlb* rlb; // If there is a request associated with the statement, prepare to // generate BLR. Otherwise assume that a request is already initialized. if (request && (request->req_flags & (REQ_project | REQ_group_by))) { new_request = NULL; rlb = CHECK_RLB(request->req_blr); } else if (new_request = (qli_req*) node->nod_arg[e_fun_request]) { request = new_request; gen_request(request); const qli_msg* receive = (qli_msg*) node->nod_arg[e_fun_send]; if (receive) gen_send_receive(receive, blr_receive); const qli_msg* send = (qli_msg*) node->nod_arg[e_fun_receive]; gen_send_receive(send, blr_send); rlb = CHECK_RLB(request->req_blr); STUFF(blr_assignment); } else rlb = CHECK_RLB(request->req_blr); // Generate function body STUFF(blr_function); qli_fun* function = (qli_fun*) node->nod_arg[e_fun_function]; qli_symbol* symbol = function->fun_symbol; STUFF(symbol->sym_length); for (const UCHAR* p = (UCHAR*) symbol->sym_string; *p;) STUFF(*p++); // Generate function arguments qli_nod* args = node->nod_arg[e_fun_args]; STUFF(args->nod_count); qli_nod** ptr = args->nod_arg; for (const qli_nod* const* const end = ptr + args->nod_count; ptr < end; ptr++) gen_expression(*ptr, request); if (new_request) { gen_parameter(node->nod_import, request); gen_compile(request); } }
static void gen_for( qli_nod* node, qli_req* request) { /************************************** * * g e n _ f o r * ************************************** * * Functional description * Generate BLR for a FOR loop, included synchronization messages. * **************************************/ // If there is a request associated with the statement, prepare to // generate BLR. Otherwise assume that a request is alrealdy initialized. if (node->nod_arg[e_for_request]) { request = (qli_req*) node->nod_arg[e_for_request]; gen_request(request); } qli_rlb* rlb = CHECK_RLB(request->req_blr); // If the statement requires an end of file marker, build a BEGIN/END around // the whole statement. const qli_msg* message = (qli_msg*) node->nod_arg[e_for_receive]; if (message) STUFF(blr_begin); // If there is a message to be sent, build a receive for it if (node->nod_arg[e_for_send]) gen_send_receive((qli_msg*) node->nod_arg[e_for_send], blr_receive); // Generate the FOR loop proper. STUFF(blr_for); gen_rse(node->nod_arg[e_for_rse], request); STUFF(blr_begin); // If data is to be received (included EOF), build a send const qli_par* eof = 0; dsc desc; USHORT value; if (message) { gen_send_receive(message, blr_send); STUFF(blr_begin); // Build assigments for all values referenced. for (const qli_par* parameter = message->msg_parameters; parameter; parameter = parameter->par_next) { if (parameter->par_value) { STUFF(blr_assignment); gen_expression(parameter->par_value, request); gen_parameter(parameter, request); } } // Next, make a FALSE for the end of file parameter eof = (qli_par*) node->nod_arg[e_for_eof]; desc.dsc_dtype = dtype_short; desc.dsc_length = sizeof(SSHORT); desc.dsc_scale = 0; desc.dsc_sub_type = 0; desc.dsc_address = (UCHAR*) &value; QLI_validate_desc(desc); STUFF(blr_assignment); value = FALSE; gen_literal(&desc, request); gen_parameter(eof, request); STUFF(blr_end); } // Build the body of the loop. const qli_msg* continuation = request->req_continue; if (continuation) { STUFF(blr_label); const USHORT label = request->req_label++; STUFF(label); STUFF(blr_loop); STUFF(blr_select); gen_send_receive(continuation, blr_receive); STUFF(blr_leave); STUFF(label); } qli_nod* sub = node->nod_arg[e_for_statement]; gen_statement(sub, request); STUFF(blr_end); if (continuation) STUFF(blr_end); // Finish off by building a SEND to indicate end of file if (message) { gen_send_receive(message, blr_send); STUFF(blr_assignment); value = TRUE; gen_literal(&desc, request); gen_parameter(eof, request); STUFF(blr_end); } // If this is our request, compile it. if (node->nod_arg[e_for_request]) gen_compile(request); }