void cpp_gen::visit(const mfast::byte_vector_field_instruction* inst, void*) { gen_field(inst, gen_op_context(inst->name(), inst->op_context()), "byte_vector"); if (inst->initial_value().is_empty()) { out_ << " "<< "byte_vector_value_storage()"; } else { out_ << " "<< "byte_vector_value_storage(\""; const char* val = static_cast<const char*>(inst->initial_value().of_array.content_); for (std::size_t i = 0; i < inst->initial_value().array_length(); ++i) { out_ << "\\x" << std::hex << std::setfill('0') << std::setw(2) << (int) val[i]; } out_<< "\"," << inst->initial_value().array_length() << ")"; } if (inst->length_name()) { out_ << ", // initial value\n" << " " << inst->length_id() << ", // length id\n" << " \"" << inst->length_name() << "\", // length name\n" << " \"" << inst->length_ns() << "\"); // length ns\n\n"; } else { out_ << "); // initial value\n\n"; } }
void cpp_gen::visit(const mfast::decimal_field_instruction* inst, void*) { std::string name( cpp_name( inst ) ); if (inst->mantissa_instruction() ) { // it has a separate mantissa instruction std::string mantisa_name(name); mantisa_name += "_mantissa"; std::string context = gen_op_context(mantisa_name.c_str(), inst->mantissa_instruction()->op_context()); out_ << "static mantissa_field_instruction\n" << prefix_string() << mantisa_name << "_instruction(\n" << " " << get_operator_name(inst->mantissa_instruction()) << ",\n" << " "<< context << ", // mantissa opContext\n" << " int_value_storage<int64_t>(" << get_initial_value<int64_t>(inst->mantissa_instruction()->initial_value(), "LL") << "));// mantissa inital value\n\n"; } gen_field(inst, gen_op_context(inst->name(), inst->op_context()), "decimal"); if ( inst->mantissa_instruction() ) { out_ << " &" << prefix_string() << name << "_mantissa_instruction,\n"; } const mfast::value_storage& init_value = inst->initial_value(); out_ << " decimal_value_storage("; if (!init_value.is_empty()) out_ << init_value.of_decimal.mantissa_ << "LL, " << static_cast<int> (init_value.of_decimal.exponent_); out_ << ")); // initial_value\n\n"; }
void cpp_gen::gen_integer(const mfast::integer_field_instruction_base* inst, const char* cpp_type, const std::string& initial_value) { gen_field(inst, gen_op_context(inst->name(), inst->op_context()), cpp_type); out_ << " int_value_storage<"<< cpp_type << "_t>(" << initial_value << ")); // initial_value\n\n"; }
void cpp_gen::gen_string(const mfast::ascii_field_instruction* inst, const char* charset) { gen_field(inst, gen_op_context(inst->name(), inst->op_context()), charset); if (inst->initial_value().is_empty()) { out_ << " "<< "string_value_storage()"; } else { out_ << " "<< "string_value_storage(\""<< inst->initial_value().get<char*>() << "\"," << inst->initial_value().array_length() << ")"; } }
static void gen_expression(qli_nod* node, qli_req* request) { /************************************** * * g e n _ e x p r e s s i o n * ************************************** * * Functional description * Generate the BLR for a boolean or value expression. * **************************************/ USHORT operatr = 0; qli_rlb* rlb = 0; if (node->nod_flags & NOD_local) { request = NULL; //return; } else if (request) rlb = CHECK_RLB(request->req_blr); switch (node->nod_type) { case nod_any: gen_any(node, request); return; case nod_unique: if (request) { STUFF(blr_unique); gen_rse(node->nod_arg[e_any_rse], request); } return; case nod_constant: if (request) gen_literal(&node->nod_desc, request); return; case nod_field: gen_field(node, request); return; case nod_format: gen_expression(node->nod_arg[e_fmt_value], request); return; case nod_map: { qli_map* map = (qli_map*) node->nod_arg[e_map_map]; const qli_ctx* context = (qli_ctx*) node->nod_arg[e_map_context]; if (context->ctx_request != request && map->map_node->nod_type == nod_field) { gen_field(map->map_node, request); return; } STUFF(blr_fid); STUFF(context->ctx_context); STUFF_WORD(map->map_position); return; } case nod_eql: operatr = blr_eql; break; case nod_neq: operatr = blr_neq; break; case nod_gtr: operatr = blr_gtr; break; case nod_geq: operatr = blr_geq; break; case nod_leq: operatr = blr_leq; break; case nod_lss: operatr = blr_lss; break; case nod_containing: operatr = blr_containing; break; case nod_matches: operatr = blr_matching; break; case nod_sleuth: operatr = blr_matching2; break; case nod_like: operatr = (node->nod_count == 2) ? blr_like : blr_ansi_like; break; case nod_starts: operatr = blr_starting; break; case nod_missing: operatr = blr_missing; break; case nod_between: operatr = blr_between; break; case nod_and: operatr = blr_and; break; case nod_or: operatr = blr_or; break; case nod_not: operatr = blr_not; break; case nod_add: operatr = blr_add; break; case nod_subtract: operatr = blr_subtract; break; case nod_multiply: operatr = blr_multiply; break; case nod_divide: operatr = blr_divide; break; case nod_negate: operatr = blr_negate; break; case nod_concatenate: operatr = blr_concatenate; break; case nod_substr: operatr = blr_substring; break; case nod_function: gen_function(node, request); return; case nod_agg_average: case nod_agg_count: case nod_agg_max: case nod_agg_min: case nod_agg_total: case nod_average: case nod_count: case nod_max: case nod_min: case nod_total: case nod_from: gen_statistical(node, request); return; case nod_rpt_average: case nod_rpt_count: case nod_rpt_max: case nod_rpt_min: case nod_rpt_total: case nod_running_total: case nod_running_count: if (node->nod_arg[e_stt_value]) gen_expression(node->nod_arg[e_stt_value], request); if (node->nod_export) gen_parameter(node->nod_export, request); request = NULL; break; case nod_prompt: case nod_variable: if (node->nod_export) gen_parameter(node->nod_export, request); return; case nod_edit_blob: case nod_reference: return; case nod_null: operatr = blr_null; break; case nod_user_name: operatr = blr_user_name; break; case nod_upcase: operatr = blr_upcase; break; case nod_lowcase: operatr = blr_lowcase; break; default: if (request && node->nod_export) { gen_parameter(node->nod_export, request); return; } ERRQ_bugcheck(353); // Msg353 gen_expression: not understood } if (request) { rlb = CHECK_RLB(request->req_blr); STUFF(operatr); } qli_nod** ptr = node->nod_arg; for (qli_nod** const end = ptr + node->nod_count; ptr < end; ptr++) gen_expression(*ptr, request); if (!node->nod_desc.dsc_address && node->nod_desc.dsc_length) CMP_alloc_temp(node); }