|
@@ -45,12 +45,14 @@ __arch_templ static int set_name(char *p, struct arch *);
|
|
|
__arch_templ static int math_set_name(char *p, struct arch *);
|
|
__arch_templ static int math_set_name(char *p, struct arch *);
|
|
|
__arch_templ static int declare_object(char *p, struct arch *);
|
|
__arch_templ static int declare_object(char *p, struct arch *);
|
|
|
|
|
|
|
|
|
|
+__arch_templ int cstyle_declare(char *p, struct arch *);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
__arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
__arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
|
psave = p;
|
|
psave = p;
|
|
|
|
|
|
|
|
- if (p == line_eof)
|
|
|
|
|
|
|
+ if (unlikely(p == line_eof))
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
switch (*p) {
|
|
switch (*p) {
|
|
@@ -68,10 +70,13 @@ __arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case '!':
|
|
case '!':
|
|
|
- if (!arch_fn->arch_stack_dump)
|
|
|
|
|
- exit(generic_error("unsupported 'stack-dump' in current mode", psave, lno));
|
|
|
|
|
|
|
+ p++;
|
|
|
|
|
+ _skip_spaces(p);
|
|
|
|
|
|
|
|
- arch_fn->arch_stack_dump();
|
|
|
|
|
|
|
+ if (likely(!arch_fn->arch_dump))
|
|
|
|
|
+ exit(generic_error("unsupported dumping in current mode", psave, lno));
|
|
|
|
|
+
|
|
|
|
|
+ arch_fn->arch_dump(getattrmask(p, dump_attrtab));
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -81,7 +86,9 @@ __arch_templ int arch_do_keyword(char *p, struct arch *arch_fn) {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
|
- if (set_name(p, arch_fn) + math_set_name(p, arch_fn) == 0)
|
|
|
|
|
|
|
+ if (unlikely(!set_name(p, arch_fn) &&
|
|
|
|
|
+ !math_set_name(p, arch_fn) &&
|
|
|
|
|
+ !cstyle_declare(p, arch_fn)))
|
|
|
exit(generic_error("unknow keyword", psave, lno));
|
|
exit(generic_error("unknow keyword", psave, lno));
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -97,7 +104,7 @@ __arch_templ static int new_var(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_NAME)
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_NAME))
|
|
|
exit(generic_error("a name for variable required", psave, lno));
|
|
exit(generic_error("a name for variable required", psave, lno));
|
|
|
|
|
|
|
|
name = strndup(p, out);
|
|
name = strndup(p, out);
|
|
@@ -109,7 +116,7 @@ __arch_templ static int new_var(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
case WORDTYPE_KWORD:
|
|
case WORDTYPE_KWORD:
|
|
|
- if (out != '=')
|
|
|
|
|
|
|
+ if (unlikely(out != '='))
|
|
|
exit(generic_error("keyword but it's not a '='", psave, lno));
|
|
exit(generic_error("keyword but it's not a '='", psave, lno));
|
|
|
|
|
|
|
|
++p;
|
|
++p;
|
|
@@ -117,7 +124,7 @@ __arch_templ static int new_var(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_NR)
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_NR))
|
|
|
exit(generic_error("a number required", psave, lno));
|
|
exit(generic_error("a number required", psave, lno));
|
|
|
|
|
|
|
|
_skip_word(p);
|
|
_skip_word(p);
|
|
@@ -174,7 +181,7 @@ static int set_name(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_NR)
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_NR))
|
|
|
exit(generic_error("a number required", psave, lno));
|
|
exit(generic_error("a number required", psave, lno));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -205,13 +212,13 @@ static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
_skip_word(p);
|
|
_skip_word(p);
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_KWORD || out != '-')
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_KWORD || out != '-'))
|
|
|
exit(generic_error("a '->' required", psave, lno));
|
|
exit(generic_error("a '->' required", psave, lno));
|
|
|
|
|
|
|
|
p++;
|
|
p++;
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_KWORD || out != '>')
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_KWORD || out != '>'))
|
|
|
exit(generic_error("a '->' required", psave, lno));
|
|
exit(generic_error("a '->' required", psave, lno));
|
|
|
|
|
|
|
|
p++;
|
|
p++;
|
|
@@ -219,7 +226,7 @@ static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
getword(p, &type, &out);
|
|
getword(p, &type, &out);
|
|
|
|
|
|
|
|
- if (type != WORDTYPE_NAME)
|
|
|
|
|
|
|
+ if (unlikely(type != WORDTYPE_NAME))
|
|
|
exit(generic_error("a name required", psave, lno));
|
|
exit(generic_error("a name required", psave, lno));
|
|
|
|
|
|
|
|
name = strndup(p, out);
|
|
name = strndup(p, out);
|
|
@@ -232,6 +239,17 @@ static int math_set_name(char *p, struct arch *arch_fn) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+static int name_defined(char *name) {
|
|
|
|
|
+ struct klist_node *n;
|
|
|
|
|
+
|
|
|
|
|
+ for (n = names_list.next; n != &names_list; n = n->next)
|
|
|
|
|
+ if (!strcmp(n->payload, name))
|
|
|
|
|
+ return 1;
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* 1.
|
|
* 1.
|
|
|
* < "libfoo.a" @ dynalib;
|
|
* < "libfoo.a" @ dynalib;
|
|
@@ -261,7 +279,7 @@ static int declare_object(char *p, struct arch *arch_fn) {
|
|
|
_skip_spaces(p);
|
|
_skip_spaces(p);
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (!getword(p, &type, &out))
|
|
|
|
|
|
|
+ if (unlikely(!getword(p, &type, &out)))
|
|
|
exit(generic_error("a module name or object name required", psave, lno));
|
|
exit(generic_error("a module name or object name required", psave, lno));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -277,7 +295,7 @@ static int declare_object(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
p += out + 2;
|
|
p += out + 2;
|
|
|
|
|
|
|
|
- free(name);
|
|
|
|
|
|
|
+ /* we will not free the name because interp_libs_dump uses it */
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -292,6 +310,7 @@ static int declare_object(char *p, struct arch *arch_fn) {
|
|
|
klist_init(n);
|
|
klist_init(n);
|
|
|
|
|
|
|
|
n->payload = name;
|
|
n->payload = name;
|
|
|
|
|
+
|
|
|
klist_add(&names_list, n);
|
|
klist_add(&names_list, n);
|
|
|
|
|
|
|
|
guess = NAMES;
|
|
guess = NAMES;
|
|
@@ -344,14 +363,14 @@ static int declare_object(char *p, struct arch *arch_fn) {
|
|
|
_skip_spaces(p);
|
|
_skip_spaces(p);
|
|
|
|
|
|
|
|
for (;;) {
|
|
for (;;) {
|
|
|
- if (!getword(p, &type, &out))
|
|
|
|
|
|
|
+ if (unlikely(!getword(p, &type, &out)))
|
|
|
/* end but no ')' */
|
|
/* end but no ')' */
|
|
|
exit(generic_error("argument list terminated with no ')'", psave, lno));
|
|
exit(generic_error("argument list terminated with no ')'", psave, lno));
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
case WORDTYPE_KWORD:
|
|
case WORDTYPE_KWORD:
|
|
|
- if (out != ')' && out != ',')
|
|
|
|
|
|
|
+ if (unlikely(out != ')' && out != ','))
|
|
|
exit(generic_error("invalid operators between arguments", psave, lno));
|
|
exit(generic_error("invalid operators between arguments", psave, lno));
|
|
|
|
|
|
|
|
if (out == ')') {
|
|
if (out == ')') {
|
|
@@ -390,7 +409,7 @@ static int declare_object(char *p, struct arch *arch_fn) {
|
|
|
|
|
|
|
|
skip: attr = getattrmask(p, declare_attrtab);
|
|
skip: attr = getattrmask(p, declare_attrtab);
|
|
|
|
|
|
|
|
- if (!attr && guess != SHARED)
|
|
|
|
|
|
|
+ if (unlikely(!attr && guess != SHARED))
|
|
|
exit(generic_error("you must give attributes for declares", psave, lno));
|
|
exit(generic_error("you must give attributes for declares", psave, lno));
|
|
|
|
|
|
|
|
if (guess != SHARED) {
|
|
if (guess != SHARED) {
|
|
@@ -398,7 +417,7 @@ skip: attr = getattrmask(p, declare_attrtab);
|
|
|
n->value |= DECLARE_FN;
|
|
n->value |= DECLARE_FN;
|
|
|
|
|
|
|
|
else if (attr & 4) {
|
|
else if (attr & 4) {
|
|
|
- if (guess == FUNCTION)
|
|
|
|
|
|
|
+ if (unlikely(guess == FUNCTION))
|
|
|
exit(generic_error("you gave us a function declare but told us this is a variable declare? ",
|
|
exit(generic_error("you gave us a function declare but told us this is a variable declare? ",
|
|
|
psave, lno));
|
|
psave, lno));
|
|
|
|
|
|
|
@@ -410,10 +429,14 @@ skip: attr = getattrmask(p, declare_attrtab);
|
|
|
exit(generic_error("one of 'fn' or 'var' must be gave", psave, lno));
|
|
exit(generic_error("one of 'fn' or 'var' must be gave", psave, lno));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (unlikely(name_defined(n->payload))) {
|
|
|
|
|
+ error((char *) n->payload);
|
|
|
|
|
+
|
|
|
|
|
+ exit(generic_error("name already defined", psave, lno));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|