newer version
This commit is contained in:
114
lang/m2/comp/options.c
Normal file
114
lang/m2/comp/options.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* U S E R O P T I O N - H A N D L I N G */
|
||||
|
||||
static char *RcsId = "$Header$";
|
||||
|
||||
#include <em_arith.h>
|
||||
#include <em_label.h>
|
||||
|
||||
#include "idfsize.h"
|
||||
|
||||
#include "type.h"
|
||||
|
||||
extern char options[];
|
||||
extern int idfsize;
|
||||
|
||||
do_option(text)
|
||||
char *text;
|
||||
{
|
||||
switch(*text++) {
|
||||
|
||||
default:
|
||||
options[text[-1]] = 1; /* flags, debug options etc. */
|
||||
break;
|
||||
|
||||
case 'L' :
|
||||
warning("-L: default no EM profiling; use -p for EM profiling");
|
||||
break;
|
||||
|
||||
case 'M': /* maximum identifier length */
|
||||
idfsize = txt2int(&text);
|
||||
if (*text || idfsize <= 0)
|
||||
fatal("malformed -M option");
|
||||
if (idfsize > IDFSIZE)
|
||||
fatal("maximum identifier length is %d", IDFSIZE);
|
||||
break;
|
||||
|
||||
case 'p' : /* generate profiling code (fil/lin) */
|
||||
options['p'] = 1;
|
||||
break;
|
||||
|
||||
case 'V' : /* set object sizes and alignment requirements */
|
||||
{
|
||||
arith size;
|
||||
int align;
|
||||
char c;
|
||||
|
||||
while (c = *text++) {
|
||||
size = txt2int(&text);
|
||||
align = 0;
|
||||
if (*text == '.') {
|
||||
text++;
|
||||
align = txt2int(&text);
|
||||
}
|
||||
switch (c) {
|
||||
|
||||
case 'w': /* word */
|
||||
if (size != (arith)0) word_size = size;
|
||||
if (align != 0) word_align = align;
|
||||
break;
|
||||
case 'i': /* int */
|
||||
if (size != (arith)0) int_size = size;
|
||||
if (align != 0) int_align = align;
|
||||
break;
|
||||
case 'l': /* longint */
|
||||
if (size != (arith)0) long_size = size;
|
||||
if (align != 0) long_align = align;
|
||||
break;
|
||||
case 'f': /* real */
|
||||
if (size != (arith)0) float_size = size;
|
||||
if (align != 0) float_align = align;
|
||||
break;
|
||||
case 'd': /* longreal */
|
||||
if (size != (arith)0) double_size = size;
|
||||
if (align != 0) double_align = align;
|
||||
break;
|
||||
case 'p': /* pointer */
|
||||
if (size != (arith)0) pointer_size = size;
|
||||
if (align != 0) pointer_align = align;
|
||||
break;
|
||||
case 'S': /* initial record alignment */
|
||||
if (align != (arith)0) struct_align = align;
|
||||
break;
|
||||
default:
|
||||
error("-V: bad type indicator %c\n", c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n':
|
||||
options['n'] = 1; /* use no registers */
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
options['w'] = 1; /* no warnings will be given */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
txt2int(tp)
|
||||
char **tp;
|
||||
{
|
||||
/* the integer pointed to by *tp is read, while increasing
|
||||
*tp; the resulting value is yielded.
|
||||
*/
|
||||
register int val = 0;
|
||||
register int ch;
|
||||
|
||||
while (ch = **tp, ch >= '0' && ch <= '9') {
|
||||
val = val * 10 + ch - '0';
|
||||
(*tp)++;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
Reference in New Issue
Block a user