const ACTION: SCT_ALLOC is action "SCT_ALLOC";
const ACTION: SCT_CPY is action "SCT_CPY";
const ACTION: SCT_SELECT is action "SCT_SELECT";
const proc: process (SCT_ALLOC, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func
local
var type: param_type is void;
var expr_type: c_param1 is expr_type.value;
begin
param_type := getExprResultType(params[1]);
prepareAnyParamTemporarys(params[1], c_param1, c_expr);
c_expr.expr &:= "/* SCT_ALLOC */ (objRefType)(";
if c_param1.result_expr <> "" then
c_expr.expr &:= c_param1.result_expr;
else
typeCategory @:= [param_type] STRUCTOBJECT;
process_create_declaration(param_type, global_c_expr);
process_create_call(param_type,
c_param1.expr, c_expr.expr);
end if;
c_expr.expr &:= ")";
end func;
const proc: process (SCT_CONV, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func
begin
process_expr(params[3], c_expr);
end func;
const proc: process (SCT_CPY, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func
local
var expr_type: statement is expr_type.value;
var expr_type: c_param1 is expr_type.value;
var expr_type: c_param3 is expr_type.value;
begin
statement.temp_num := c_expr.temp_num;
prepareAnyParamTemporarys(params[1], c_param1, statement);
c_param3.demand := ASSIGN_RESULT;
prepareAnyParamTemporarys(params[3], c_param3, statement);
if c_param3.result_expr <> "" then
statement.temp_decls &:= "structType new_struct;\n";
statement.expr &:= "new_struct=";
statement.expr &:= c_param3.result_expr;
statement.expr &:= ";\n";
process_destr_declaration(getExprResultType(params[1]), global_c_expr);
if isNormalVariable(params[1]) then
statement.expr &:= "new_struct->type_num = (";
statement.expr &:= c_param1.expr;
statement.expr &:= ")->type_num;\n";
process_destr_call(getExprResultType(params[1]),
c_param1.expr, statement.expr);
statement.expr &:= c_param1.expr;
statement.expr &:= "=new_struct;\n";
else
statement.temp_decls &:= "structType *struct_ptr=&(";
statement.temp_decls &:= c_param1.expr;
statement.temp_decls &:= ");\n";
statement.expr &:= "new_struct->type_num = (*struct_ptr)->type_num;\n";
process_destr_call(getExprResultType(params[1]),
"*struct_ptr", statement.expr);
statement.expr &:= "*struct_ptr=new_struct;\n";
end if;
else
process_cpy_declaration(getExprResultType(params[1]), global_c_expr);
process_cpy_call(getExprResultType(params[1]),
c_param1.expr, c_param3.expr, statement.expr);
statement.expr &:= ";\n";
end if;
doLocalDeclsOfStatement(statement, c_expr);
end func;
const proc: process (SCT_SELECT, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func
local
var type: object_type is void;
begin
object_type := getExprResultType(params[1]);
if object_type in struct_element_idx and params[3] in struct_element_idx[object_type] then
c_expr.expr &:= "((structType)(";
getAnyParamToExpr(params[1], c_expr);
c_expr.expr &:= "))->stru[";
c_expr.expr &:= str(struct_element_idx[object_type][params[3]]);
c_expr.expr &:= "]";
c_expr.expr &:= select_value_from_rtlObjectStruct(resultType(getType(function)));
c_expr.expr &:= "/*->o_";
create_name2(params[3], c_expr.expr);
c_expr.expr &:= "*/";
end if;
end func;