Make a nice flag name for evaluate().

This commit is contained in:
Olaf Seibert
2021-04-21 18:34:11 +02:00
parent 2753b081cc
commit 461205d60a
4 changed files with 26 additions and 21 deletions

4
TODO
View File

@@ -4,6 +4,10 @@ listing format errors: ignore whitespace of input
documentation: print supported directives documentation: print supported directives
register symbols: %3+1 is the same as %4 (pdf page 3-9 aka 35),
but where precisely register symbols can be used, and how,
isn't specified.
--------------------------------------- ---------------------------------------
I was not able to locate a Macro-11 language reference manual any more I was not able to locate a Macro-11 language reference manual any more
recent than for RT11 version *3*, so I used that plus my recollection recent than for RT11 version *3*, so I used that plus my recollection

View File

@@ -798,12 +798,12 @@ static int assemble(
if (!label) { if (!label) {
report(stack->top, "Missing .(I)IF condition\n"); report(stack->top, "Missing .(I)IF condition\n");
} else if (strcmp(label, "DF") == 0) { } else if (strcmp(label, "DF") == 0) {
value = parse_expr(cp, 1); value = parse_expr(cp, EVALUATE_UNDEF);
cp = value->cp; cp = value->cp;
ok = eval_defined(value); ok = eval_defined(value);
free_tree(value); free_tree(value);
} else if (strcmp(label, "NDF") == 0) { } else if (strcmp(label, "NDF") == 0) {
value = parse_expr(cp, 1); value = parse_expr(cp, EVALUATE_UNDEF);
cp = value->cp; cp = value->cp;
ok = eval_undefined(value); ok = eval_undefined(value);
free_tree(value); free_tree(value);

View File

@@ -269,7 +269,7 @@ EX_TREE *dup_tree(
constant value, else a symbol plus an offset. */ constant value, else a symbol plus an offset. */
EX_TREE *evaluate( EX_TREE *evaluate(
EX_TREE *tp, EX_TREE *tp,
int undef) int flags)
{ {
EX_TREE *res; EX_TREE *res;
char *cp = tp->cp; char *cp = tp->cp;
@@ -281,7 +281,7 @@ EX_TREE *evaluate(
/* Change some symbols to "undefined" */ /* Change some symbols to "undefined" */
if (undef) { if (flags & EVALUATE_UNDEF) {
int change = 0; int change = 0;
/* I'd prefer this behavior, but MACRO.SAV is a bit too primitive. */ /* I'd prefer this behavior, but MACRO.SAV is a bit too primitive. */
@@ -338,7 +338,7 @@ EX_TREE *evaluate(
case EX_COM: case EX_COM:
/* Complement */ /* Complement */
tp = evaluate(tp->data.child.left, undef); tp = evaluate(tp->data.child.left, flags);
if (tp->type == EX_LIT) { if (tp->type == EX_LIT) {
/* Complement the literal */ /* Complement the literal */
res = new_ex_lit(~tp->data.lit); res = new_ex_lit(~tp->data.lit);
@@ -354,7 +354,7 @@ EX_TREE *evaluate(
break; break;
case EX_NEG: case EX_NEG:
tp = evaluate(tp->data.child.left, undef); tp = evaluate(tp->data.child.left, flags);
if (tp->type == EX_LIT) { if (tp->type == EX_LIT) {
/* negate literal */ /* negate literal */
res = new_ex_lit((unsigned) -(int) tp->data.lit); res = new_ex_lit((unsigned) -(int) tp->data.lit);
@@ -387,8 +387,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Both literals? Sum them and return result. */ /* Both literals? Sum them and return result. */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -463,8 +463,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Both literals? Subtract them and return a lit. */ /* Both literals? Subtract them and return a lit. */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -539,8 +539,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Can only multiply if both are literals */ /* Can only multiply if both are literals */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -601,8 +601,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Can only divide if both are literals */ /* Can only divide if both are literals */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -629,8 +629,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Operate if both are literals */ /* Operate if both are literals */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -674,8 +674,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Operate if both are literals */ /* Operate if both are literals */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {
@@ -719,8 +719,8 @@ EX_TREE *evaluate(
EX_TREE *left, EX_TREE *left,
*right; *right;
left = evaluate(tp->data.child.left, undef); left = evaluate(tp->data.child.left, flags);
right = evaluate(tp->data.child.right, undef); right = evaluate(tp->data.child.right, flags);
/* Operate if both are literals */ /* Operate if both are literals */
if (left->type == EX_LIT && right->type == EX_LIT) { if (left->type == EX_LIT && right->type == EX_LIT) {

View File

@@ -67,7 +67,8 @@ EX_TREE *new_ex_bin(
EX_TREE *evaluate( EX_TREE *evaluate(
EX_TREE *tp, EX_TREE *tp,
int undef); int flags);
#define EVALUATE_UNDEF 1
#endif #endif