Skip to content

Commit

Permalink
Introduce category POINTLISTOBJECT for pointList objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMertes committed Jan 30, 2024
1 parent 1fdb909 commit b10d3fc
Show file tree
Hide file tree
Showing 27 changed files with 707 additions and 26 deletions.
1 change: 1 addition & 0 deletions lib/category.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const category: POLLOBJECT is category("POLLOBJECT");
const category: LISTOBJECT is category("LISTOBJECT");
const category: FLOATOBJECT is category("FLOATOBJECT");
const category: WINOBJECT is category("WINOBJECT");
const category: POINTLISTOBJECT is category("POINTLISTOBJECT");
const category: PROCESSOBJECT is category("PROCESSOBJECT");
const category: ENUMLITERALOBJECT is category("ENUMLITERALOBJECT");
const category: CONSTENUMOBJECT is category("CONSTENUMOBJECT");
Expand Down
14 changes: 14 additions & 0 deletions lib/comp/action.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,20 @@ const proc: process_action (in reference: function, in ref_list: params,
process(PCS_VALUE, function, params, c_expr);
when {"PCS_WAIT_FOR"}:
process(PCS_WAIT_FOR, function, params, c_expr);
when {"PLT_BSTRING"}:
process(PLT_BSTRING, function, params, c_expr);
when {"PLT_CMP"}:
process(PLT_CMP, function, params, c_expr);
when {"PLT_CPY"}:
process(PLT_CPY, function, params, c_expr);
when {"PLT_EQ"}:
process(PLT_EQ, function, params, c_expr);
when {"PLT_HASHCODE"}:
process(PLT_HASHCODE, function, params, c_expr);
when {"PLT_NE"}:
process(PLT_NE, function, params, c_expr);
when {"PLT_VALUE"}:
process(PLT_VALUE, function, params, c_expr);
when {"POL_ADD_CHECK"}:
process(POL_ADD_CHECK, function, params, c_expr);
when {"POL_CLEAR"}:
Expand Down
3 changes: 2 additions & 1 deletion lib/comp/const.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const set of category: constantExpressionCategories is {
TYPEOBJECT, INTOBJECT, BIGINTOBJECT, CHAROBJECT, STRIOBJECT,
BSTRIOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT, SETOBJECT,
FILEOBJECT, SOCKETOBJECT, LISTOBJECT, FLOATOBJECT, WINOBJECT,
PROCESSOBJECT, ENUMLITERALOBJECT, REFLISTOBJECT, SYMBOLOBJECT};
POINTLISTOBJECT, PROCESSOBJECT, ENUMLITERALOBJECT, REFLISTOBJECT,
SYMBOLOBJECT};

const set of string: specialActions is
{"BIG_PARSE1", "BIN_AND", "BIN_OR", "BIN_XOR", "BLN_ICONV1",
Expand Down
1 change: 1 addition & 0 deletions lib/comp/copy.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ const proc: process_cpy_call (in type: object_type,
when {POLLOBJECT}: expr &:= "polCpy(" & param_a & ", " & param_b & ")";
when {REFLISTOBJECT}: expr &:= "rflCpy(&(" & param_a & "), " & param_b & ")";
when {WINOBJECT}: expr &:= "drwCpy(&(" & param_a & "), " & param_b & ")";
when {POINTLISTOBJECT}: expr &:= "bstCpy(&(" & param_a & "), " & param_b & ")";
when {PROCESSOBJECT}: expr &:= "pcsCpy(&(" & param_a & "), " & param_b & ")";
when {PROGOBJECT}: expr &:= "prgCpy(&(" & param_a & "), " & param_b & ")";
when {DATABASEOBJECT}: expr &:= "sqlCpyDb(&(" & param_a & "), " & param_b & ")";
Expand Down
1 change: 1 addition & 0 deletions lib/comp/create.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ const proc: process_create_call (in type: object_type,
when {POLLOBJECT}: expr &:= "polCreate(" & param_b & ")";
when {REFLISTOBJECT}: expr &:= "rflCreate(" & param_b & ")";
when {WINOBJECT}: expr &:= "drwCreate(" & param_b & ")";
when {POINTLISTOBJECT}: expr &:= "bstCreate(" & param_b & ")";
when {PROCESSOBJECT}: expr &:= "pcsCreate(" & param_b & ")";
when {PROGOBJECT}: expr &:= "prgCreate(" & param_b & ")";
when {DATABASEOBJECT}: expr &:= "sqlCreateDb(" & param_b & ")";
Expand Down
5 changes: 3 additions & 2 deletions lib/comp/destr.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ const proc: declare_missing_destr_declarations (inout expr_type: c_expr) is func

const set of category: destrNecessary is {
BIGINTOBJECT, STRIOBJECT, BSTRIOBJECT, FILEOBJECT, SETOBJECT,
REFLISTOBJECT, WINOBJECT, PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT,
SQLSTMTOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT};
REFLISTOBJECT, WINOBJECT, POINTLISTOBJECT, PROCESSOBJECT, PROGOBJECT,
DATABASEOBJECT, SQLSTMTOBJECT, ARRAYOBJECT, HASHOBJECT, STRUCTOBJECT};


const proc: process_destr_call (in type: object_type,
Expand All @@ -397,6 +397,7 @@ const proc: process_destr_call (in type: object_type,
when {POLLOBJECT}: expr &:= "polDestr(" & param_b & ");\n";
when {REFLISTOBJECT}: expr &:= "rflDestr(" & param_b & ");\n";
when {WINOBJECT}: expr &:= "drwDestr(" & param_b & ");\n";
when {POINTLISTOBJECT}: expr &:= "bstDestr(" & param_b & ");\n";
when {PROCESSOBJECT}: expr &:= "pcsDestr(" & param_b & ");\n";
when {PROGOBJECT}: expr &:= "prgDestr(" & param_b & ");\n";
when {DATABASEOBJECT}: expr &:= "sqlDestrDb(" & param_b & ");\n";
Expand Down
143 changes: 143 additions & 0 deletions lib/comp/drw_act.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ const ACTION: DRW_WIDTH is action "DRW_WIDTH";
const ACTION: DRW_XPOS is action "DRW_XPOS";
const ACTION: DRW_YPOS is action "DRW_YPOS";

const ACTION: PLT_BSTRING is action "PLT_BSTRING";
const ACTION: PLT_CMP is action "PLT_CMP";
const ACTION: PLT_CPY is action "PLT_CPY";
const ACTION: PLT_EQ is action "PLT_EQ";
const ACTION: PLT_HASHCODE is action "PLT_HASHCODE";
const ACTION: PLT_NE is action "PLT_NE";
const ACTION: PLT_VALUE is action "PLT_VALUE";


const proc: constructRgbMacroPart (in string: colorName, in integer: colorMask,
inout string: macroBody) is func
Expand Down Expand Up @@ -227,6 +235,8 @@ const proc: drw_prototypes (inout file: c_prog) is func
declareExtern(c_prog, "intType drwWidth (const_winType);");
declareExtern(c_prog, "intType drwXPos (const_winType);");
declareExtern(c_prog, "intType drwYPos (const_winType);");

declareExtern(c_prog, "bstriType pltValue (const const_objRefType);");
end func;


Expand Down Expand Up @@ -1416,3 +1426,136 @@ const proc: process (DRW_YPOS, in reference: function,
getAnyParamToExpr(params[1], c_expr);
c_expr.expr &:= ")";
end func;


const proc: process (PLT_BSTRING, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

begin
c_expr.expr &:= "(";
process_expr(params[1], c_expr);
c_expr.expr &:= ")";
end func;


const proc: process (PLT_CMP, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

begin
c_expr.expr &:= "bstCmp(";
getAnyParamToExpr(params[1], c_expr);
c_expr.expr &:= ", ";
getAnyParamToExpr(params[2], c_expr);
c_expr.expr &:= ")";
end func;


const proc: process (PLT_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
if isNormalVariable(params[1]) then
statement.temp_decls &:= "bstriType old_bstri=";
statement.temp_decls &:= c_param1.expr;
statement.temp_decls &:= ";\n";
statement.expr &:= c_param1.expr;
statement.expr &:= "=";
else
statement.temp_decls &:= "bstriType *bstri_ptr=&(";
statement.temp_decls &:= c_param1.expr;
statement.temp_decls &:= ");\n";
statement.temp_decls &:= "bstriType old_bstri=*bstri_ptr;\n";
statement.expr &:= "*bstri_ptr=";
end if;
statement.expr &:= c_param3.result_expr;
statement.expr &:= ";\n";
statement.expr &:= "bstDestr(old_bstri);\n";
else
statement.expr &:= "bstCpy(&(";
statement.expr &:= c_param1.expr;
statement.expr &:= "), ";
statement.expr &:= c_param3.expr;
statement.expr &:= ");\n";
end if;
doLocalDeclsOfStatement(statement, c_expr);
end func;


const proc: process (PLT_EQ, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

local
var string: bstri_a_name is "";
var string: bstri_b_name is "";
begin
c_expr.expr &:= "(";
bstri_a_name := getParameterAsVariable("const_bstriType", "tmp_a_", params[1], c_expr);
bstri_b_name := getParameterAsVariable("const_bstriType", "tmp_b_", params[3], c_expr);
(* Formula used: (a->size==b->size&&memcmp(a->mem,b->mem,
a->size*sizeof(unsigned char))==0) *)
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->size==";
c_expr.expr &:= bstri_b_name;
c_expr.expr &:= "->size&&memcmp(";
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->mem,";
c_expr.expr &:= bstri_b_name;
c_expr.expr &:= "->mem,";
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->size*sizeof(unsigned char))==0)";
end func;


const proc: process (PLT_HASHCODE, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

begin
c_expr.expr &:= "bstHashCode(";
getAnyParamToExpr(params[1], c_expr);
c_expr.expr &:= ")";
end func;


const proc: process (PLT_NE, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

local
var string: bstri_a_name is "";
var string: bstri_b_name is "";
begin
c_expr.expr &:= "(";
bstri_a_name := getParameterAsVariable("const_bstriType", "tmp_a_", params[1], c_expr);
bstri_b_name := getParameterAsVariable("const_bstriType", "tmp_b_", params[3], c_expr);
(* Formula used: (a->size!=b->size||memcmp(a->mem,b->mem,
a->size*sizeof(unsigned char))!=0) *)
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->size!=";
c_expr.expr &:= bstri_b_name;
c_expr.expr &:= "->size||memcmp(";
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->mem,";
c_expr.expr &:= bstri_b_name;
c_expr.expr &:= "->mem,";
c_expr.expr &:= bstri_a_name;
c_expr.expr &:= "->size*sizeof(unsigned char))!=0)";
end func;


const proc: process (PLT_VALUE, in reference: function,
in ref_list: params, inout expr_type: c_expr) is func

begin
prepare_bstri_result(c_expr);
c_expr.result_expr := "pltValue(";
getStdParamToResultExpr(params[1], c_expr);
c_expr.result_expr &:= ")";
end func;
5 changes: 3 additions & 2 deletions lib/comp/expr_utl.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,9 @@ const func boolean: isNormalVariable (in reference: a_param) is
CHAROBJECT, STRIOBJECT, BSTRIOBJECT, ARRAYOBJECT, HASHOBJECT,
STRUCTOBJECT, INTERFACEOBJECT, SETOBJECT, FILEOBJECT,
SOCKETOBJECT, POLLOBJECT, LISTOBJECT, FLOATOBJECT, WINOBJECT,
PROCESSOBJECT, REFOBJECT, REFLISTOBJECT, ACTOBJECT, VALUEPARAMOBJECT,
REFPARAMOBJECT, RESULTOBJECT, LOCALVOBJECT, PROGOBJECT};
POINTLISTOBJECT, PROCESSOBJECT, REFOBJECT, REFLISTOBJECT,
ACTOBJECT, VALUEPARAMOBJECT, REFPARAMOBJECT, RESULTOBJECT,
LOCALVOBJECT, PROGOBJECT};


const func string: normalVariable (in reference: aParam, inout expr_type: c_expr) is func
Expand Down
21 changes: 21 additions & 0 deletions lib/comp/literal.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ const type: win_bstri_hash is hash [integer] integer;
var win_table_hash: win_const_table is win_table_hash.EMPTY_HASH;
var win_bstri_hash: win_bstri_table is win_bstri_hash.EMPTY_HASH;

const type: plist_table_hash is hash [pointList] integer;
const type: plist_index_hash is hash [integer] array pointList;
const type: plist_bstri_hash is hash [integer] integer;

var plist_table_hash: plist_const_table is plist_table_hash.EMPTY_HASH;
var plist_bstri_hash: plist_bstri_table is plist_bstri_hash.EMPTY_HASH;

const type: const_table_hash is hash [reference] integer;
const type: const_index_hash is hash [integer] array reference;

Expand Down Expand Up @@ -284,3 +291,17 @@ const func string: windowLiteral (in PRIMITIVE_WINDOW: aWindow) is func
expr &:= str(win_const_table[aWindow]);
expr &:= "]";
end func;


const func string: pointListLiteral (in pointList: aPointList) is func

result
var string: expr is "";
begin
if aPointList not in plist_const_table then
plist_const_table @:= [aPointList] length(plist_const_table);
end if;
expr &:= "plist[";
expr &:= str(plist_const_table[aPointList]);
expr &:= "]";
end func;
2 changes: 2 additions & 0 deletions lib/comp/ref_act.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ const proc: process (REF_TRACE, in reference: function,
c_expr.expr &:= "printf(\" window [%lu] %lu\", win->usage_count, win);\n";
c_expr.expr &:= "}\n";
c_expr.expr &:= "}\n";
when {POINTLISTOBJECT}:
c_expr.expr &:= "printf(\"<POINTLISTOBJECT>\")";
when {PROCESSOBJECT}:
c_expr.expr &:= "{\n";
c_expr.expr &:= "processType process=";
Expand Down
7 changes: 5 additions & 2 deletions lib/comp/type.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const func string: raw_type_name (in type: object_type) is func
when {POLLOBJECT}: typeName := "pollType";
when {SETOBJECT}: typeName := "setType";
when {WINOBJECT}: typeName := "winType";
when {POINTLISTOBJECT}: typeName := "bstriType";
when {PROCESSOBJECT}: typeName := "processType";
when {PROGOBJECT}: typeName := "progType";
when {DATABASEOBJECT}: typeName := "databaseType";
Expand Down Expand Up @@ -192,6 +193,7 @@ const func string: raw_type_value (in type: object_type) is func
when {POLLOBJECT}: valueName := "pollValue";
when {SETOBJECT}: valueName := "setValue";
when {WINOBJECT}: valueName := "winValue";
when {POINTLISTOBJECT}: valueName := "bstriValue";
when {PROCESSOBJECT}: valueName := "processValue";
when {PROGOBJECT}: valueName := "progValue";
when {DATABASEOBJECT}: valueName := "databaseValue";
Expand Down Expand Up @@ -227,8 +229,9 @@ const func boolean: valueIsAtHeap (in type: aType) is func
local
const set of category: heapCategories is {
BIGINTOBJECT, STRIOBJECT, BSTRIOBJECT, FILEOBJECT, WINOBJECT,
PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT, SQLSTMTOBJECT, SETOBJECT,
ARRAYOBJECT, STRUCTOBJECT, HASHOBJECT, INTERFACEOBJECT, REFLISTOBJECT};
POINTLISTOBJECT, PROCESSOBJECT, PROGOBJECT, DATABASEOBJECT,
SQLSTMTOBJECT, SETOBJECT, ARRAYOBJECT, STRUCTOBJECT, HASHOBJECT,
INTERFACEOBJECT, REFLISTOBJECT};
begin
if aType in typeCategory and typeCategory[aType] in heapCategories then
isAtHeap := TRUE;
Expand Down
17 changes: 13 additions & 4 deletions lib/graph.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,22 @@ const type: pointList is newtype;

IN_PARAM_IS_REFERENCE(pointList);

const proc: destroy (ref pointList: aValue) is action "BST_DESTR";
const proc: (ref pointList: dest) ::= (ref pointList: source) is action "BST_CREATE";
const proc: (inout pointList: dest) := (ref pointList: source) is action "BST_CPY";
const proc: destroy (ref pointList: aValue) is action "PLT_DESTR";
const proc: (ref pointList: dest) ::= (in pointList: source) is action "PLT_CREATE";
const proc: (inout pointList: dest) := (in pointList: source) is action "PLT_CPY";

const func pointList: _GENERATE_EMPTY_POINT_LIST is action "BST_EMPTY";
const func pointList: _GENERATE_EMPTY_POINT_LIST is action "PLT_EMPTY";
const pointList: (attr pointList) . value is _GENERATE_EMPTY_POINT_LIST;

const func bstring: bstring (in pointList: aPointList) is action "PLT_BSTRING";

const func boolean: (in pointList: pointList1) = (in pointList: pointList2) is action "PLT_EQ";
const func boolean: (in pointList: pointList1) <> (in pointList: pointList2) is action "PLT_NE";

const func integer: hashCode (in pointList: aPointList) is action "PLT_HASHCODE";
const func integer: compare (in pointList: pointList1,
in pointList: pointList2) is action "PLT_CMP";

(**
* The function 'genPointList' creates a 'pointList'.
* It converts an array of alternate x and y values to a 'pointList'.
Expand Down
1 change: 1 addition & 0 deletions lib/progs.s7i
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ const func float: getValue (in reference: aReference, attr float) is
const func reference: getValue (in reference: aReference, attr reference) is action "REF_VALUE";
const func PRIMITIVE_WINDOW: getValue (in reference: aReference,
attr PRIMITIVE_WINDOW) is action "DRW_VALUE";
const func pointList: getValue (in reference: aReference, attr pointList) is action "PLT_VALUE";
const func process: getValue (in reference: aReference, attr process) is action "PCS_VALUE";
# const func type: getValue (in reference: aReference, attr type) is action "TYP_VALUE";

Expand Down
Loading

0 comments on commit b10d3fc

Please sign in to comment.