Skip to content

Commit 5ad773c

Browse files
committed
Fix lots of problems with old engine ECL
- t format is recognized - Timelines can now use n/N formats - A new T format for resolving timelines by name - Lots of format table corrections - Versions before IN did not have rank masks for timelines, instead using that field for a larger size parameter. Trying to give timeline instructions a rank mask previously just crashed, so disable doing that. - Versions after IN got rid of the embedded arg0, instead using that field for a larger time parameter.
1 parent bff8d2e commit 5ad773c

File tree

5 files changed

+558
-328
lines changed

5 files changed

+558
-328
lines changed

thecl/ecsparse.y

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ ArgumentDeclaration:
601601
Instructions:
602602
%empty
603603
| Instructions INTEGER ':' { set_time(state, $2); }
604+
| Instructions '-' INTEGER ':' { set_time(state, -$3); }
604605
| Instructions '+' INTEGER ':' { set_time(state, state->instr_time + $3); }
605606
| Instructions IDENTIFIER ':' { label_create(state, $2); free($2); }
606607
| Instructions Instruction ';'
@@ -1307,6 +1308,19 @@ ExpressionCall:
13071308
ExpressionSubset:
13081309
ExpressionSubsetNoUnaryPlus
13091310
| '+' Expression %prec T_NEG { $$ = $2; }
1311+
| '-' Expression %prec T_NEG {
1312+
if (is_post_th125(state->version)) {
1313+
$$ = EXPR_21(NEGI, NEGF, $2);
1314+
} else {
1315+
thecl_param_t* p = param_new($2->result_type);
1316+
if (p->value.type == 'f') {
1317+
p->value.val.f = 0;
1318+
$$ = EXPR_12(SUBTRACTF, expression_load_new(state, p), $2);
1319+
} else {
1320+
$$ = EXPR_11(NEGI, $2);
1321+
}
1322+
}
1323+
}
13101324
;
13111325

13121326
ExpressionSubsetNoUnaryPlus:
@@ -1336,19 +1350,6 @@ ExpressionSubsetNoUnaryPlus:
13361350
if ($1->value.val.S >= 0) /* Stack variables only. This is also verrfied to be int by expression creation. */
13371351
state->current_sub->vars[$1->value.val.S / 4]->is_written = true;
13381352
}
1339-
| '-' Expression %prec T_NEG {
1340-
if (is_post_th125(state->version)) {
1341-
$$ = EXPR_21(NEGI, NEGF, $2);
1342-
} else {
1343-
thecl_param_t* p = param_new($2->result_type);
1344-
if (p->value.type == 'f') {
1345-
p->value.val.f = 0;
1346-
$$ = EXPR_12(SUBTRACTF, expression_load_new(state, p), $2);
1347-
} else {
1348-
$$ = EXPR_11(NEGI, $2);
1349-
}
1350-
}
1351-
}
13521353
;
13531354

13541355
Address:
@@ -1529,8 +1530,8 @@ instr_set_types(
15291530

15301531
if (new_type != param->type &&
15311532
!(param->type == 'D' && new_type == 'H') &&
1532-
!(param->type == 'z' && (new_type == 'm' || new_type == 'x' || new_type == 'N' || new_type == 'n')) &&
1533-
!(param->type == 'S' && (new_type == 's' || new_type == 'U' || new_type == 't'))
1533+
!(param->type == 'z' && (new_type == 'm' || new_type == 'x' || new_type == 'N' || new_type == 'n' || new_type == 'T')) &&
1534+
!(param->type == 'S' && (new_type == 's' || new_type == 'U' || new_type == 'u' || new_type == 't' || new_type == 'C' || new_type == 'N' || new_type == 'n'))
15341535
) {
15351536
seqmap_entry_t* ent = seqmap_get(g_eclmap->ins_names, instr->id);
15361537
char buf[128];

thecl/expr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ expr_get_by_symbol(
198198
ret = expr_get_by_symbol_from_table(th10_expressions, symbol);
199199
break;
200200
case VER_PRE_TH10:
201+
case VER_PRE_TH8:
201202
ret = expr_get_by_symbol_from_table(th06_expressions, symbol);
202203
}
203204

@@ -240,6 +241,7 @@ expr_get_by_id(
240241
ret = expr_get_by_id_from_table(th10_expressions, id);
241242
break;
242243
case VER_PRE_TH10:
244+
case VER_PRE_TH8:
243245
ret = expr_get_by_id_from_table(th06_expressions, id);
244246
}
245247

thecl/thecl.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,27 @@ free_globals(void)
223223
}
224224

225225
bool
226-
is_post_th10(
227-
unsigned int version)
228-
{
226+
is_pre_th8(unsigned int version) {
227+
switch (version) {
228+
case 6: case 7: return true;
229+
default: return false;
230+
}
231+
}
232+
233+
bool
234+
is_post_th10(unsigned int version) {
229235
switch(version) {
230-
case 6: case 7: case 8: case 9: case 95: return false;
236+
case 6: case 7:
237+
case 8: case 9: case 95: return false;
231238
default: return true;
232239
}
233240
}
234241

235242
bool
236243
is_post_alcostg(unsigned int version) {
237244
switch (version) {
238-
case 6: case 7: case 8: case 9: case 95:
245+
case 6: case 7:
246+
case 8: case 9: case 95:
239247
case 10: return false;
240248
default: return true;
241249
}
@@ -244,7 +252,8 @@ is_post_alcostg(unsigned int version) {
244252
bool
245253
is_post_th125(unsigned int version) {
246254
switch (version) {
247-
case 6: case 7: case 8: case 9: case 95:
255+
case 6: case 7:
256+
case 8: case 9: case 95:
248257
case 10:
249258
case 103: case 11: case 12: return false;
250259
default: return true;
@@ -254,7 +263,8 @@ is_post_th125(unsigned int version) {
254263
bool
255264
is_post_th13(unsigned int version) {
256265
switch(version) {
257-
case 6: case 7: case 8: case 9: case 95:
266+
case 6: case 7:
267+
case 8: case 9: case 95:
258268
case 10:
259269
case 103: case 11: case 12:
260270
case 125: case 128: return false;
@@ -273,8 +283,10 @@ engine_version(unsigned int version) {
273283
return VER_POST_ALCOSTG;
274284
case 10:
275285
return VER_POST_TH10;
276-
case 6: case 7: case 8: case 9: case 95:
286+
case 8: case 9: case 95:
277287
return VER_PRE_TH10;
288+
case 6: case 7:
289+
return VER_PRE_TH8;
278290
}
279291
}
280292

thecl/thecl.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ thecl_param_t* param_copy(
103103
void param_free(
104104
thecl_param_t* param);
105105

106+
bool is_pre_th8(
107+
unsigned int version);
108+
106109
bool is_post_th10(
107110
unsigned int version);
108111

@@ -116,11 +119,12 @@ bool is_post_th13(
116119
unsigned int version);
117120

118121
typedef enum {
119-
VER_PRE_TH10,
120-
VER_POST_TH10,
121-
VER_POST_ALCOSTG,
122-
VER_POST_TH125,
123-
VER_POST_TH13
122+
VER_PRE_TH8, /* Timeline instructions don't support rank and include arg0 */
123+
VER_PRE_TH10, /* Timeline instructions support rank and time is 32 bit with no arg0 */
124+
VER_POST_TH10, /* New engine */
125+
VER_POST_ALCOSTG, /* SQRT exists */
126+
VER_POST_TH125, /* NEGF is no longer broken */
127+
VER_POST_TH13 /* NEGI/NEGF change indices */
124128
} thecl_engine_version;
125129

126130
thecl_engine_version engine_version(

0 commit comments

Comments
 (0)