Commit Graph

290 Commits

Author SHA1 Message Date
Cyrill Gorcunov
6b4a64167c preproc: Drop emitting() rudimanet
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-01 00:20:13 +04:00
Cyrill Gorcunov
f30cf73533 preproc: Align members in structures
For easier reading

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:20:14 +04:00
Cyrill Gorcunov
d57a031616 preproc: Reorder ExpInv to drop padding
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:11:08 +04:00
Cyrill Gorcunov
10083ae953 preproc: Reorder SMacro members to eliminate padding
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:06:20 +04:00
Cyrill Gorcunov
4e40962918 preproc: Drop useless assignments
new_ExpDef does zalloc'ate memory so no need
to assign zeros again.

Same time it should fix MSC complains on NULL assignment
on boolean variable.

Reported-by: Jasper Neuman <jasper.neumann@web.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-06 23:12:55 +04:00
Cyrill Gorcunov
86b2ad05f8 preproc: Move Preproc type to preproc_ops structure
There is no need to hide this structure into a type.
The former preproc_ops is a way more descriptive.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-02 00:15:24 +04:00
Cyrill Gorcunov
0ad6a7b293 preproc: Refactor smacro paramters expansion
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 01:36:45 +04:00
Cyrill Gorcunov
194ba892ca preproc: Add smacro paramter helpers
I belive this should simply code a bit.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 01:16:35 +04:00
Cyrill Gorcunov
5b6c96b9fd preproc: Alignment in loop
Just for easier reading

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 00:22:53 +04:00
Cyrill Gorcunov
290eac7569 preproc: Finally drop context-through search
2.09 series was the last one we support context-thru search
(and we were issuing a warning about that) so drop all-context
from get_ctx() routine.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-28 02:01:47 +04:00
Cyrill Gorcunov
b6c6ca96e7 preproc: nasm_free is safe against NULL argument
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-28 01:33:02 +04:00
Cyrill Gorcunov
c6a742cb6b Revert "BR3288901: Relax concat rules in preprocessor code"
This reverts commit cb00cd1ba7.

As Victor pointed out some tests do not pass with this commit
so revert it until things get fixed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-27 01:23:09 +04:00
Cyrill Gorcunov
fdd0ac5f43 preproc: Add trace point into paste_tokens
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-27 01:22:27 +04:00
Cyrill Gorcunov
2e04600e3d preproc: Some more tracing calls
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26 23:33:56 +04:00
Cyrill Gorcunov
9d1141aea9 preproc: Missed double charp in nasm_trace
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26 23:07:35 +04:00
Cyrill Gorcunov
fc0c1281db preproc: Add tokenization tracing
It's a bit more than that, also TRACE=1 make
flag added to run this facility on and off
at compiling time.

Debug feature only, doesn't affect regular users.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 19:51:44 +04:00
Cyrill Gorcunov
82667ff5d3 preproc.c: Get rid of a few tabs and update year
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 19:34:19 +04:00
Cyrill Gorcunov
3eba69a63a preproc.c: Use list_reverse helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 18:16:54 +04:00
Cyrill Gorcunov
fb27fc21e7 preproc: Drop unused 'mtok' variable
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 12:08:30 +04:00
Cyrill Gorcunov
cb00cd1ba7 BR3288901: Relax concat rules in preprocessor code
We simply allow the following terminals to be concat'ed
if they are written without space or any other separator
inbetween.

        a := id | preproc-id | number | float | other
        b := id | preproc-id | number | float | other

        if match(a,b):
                s := concat(a,b)
                re-tokenize(s)

Basically it means it's up to code author to write
preproc code a way the sane production appears.

Some notes.

1) We don't concat strings.

2) The 'weirdpaste' test fails now because with relaxed
   rules it works as needed and was borken before.

   The lacmus snippet is

        %define N 1e%++%+ 5
        dd N, 1e+5

Previously the output was

        dd 1e+%+ 5, 1e+5

which is wrong since we have explicit concat here
with %+ operator. The new code production is correct
and looks like

        dd 1e+5, 1e+5

as expected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 12:03:36 +04:00
Cyrill Gorcunov
a09fe1ebfb Merge branch 'nasm-2.09.xx'
Conflicts:
	doc/changes.src
	version

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-12 22:35:42 +03:00
Cyrill Gorcunov
d34a1085b5 preproc.c: Don't forget to dup filename before free
src_set_fname simply gets copy of pointer (ideally
we need refcounting here) so don't pass the name
which will be freed soon but rather pass a copy.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-07 11:23:08 +03:00
Cyrill Gorcunov
8dcfd883c7 preproc.c: Fix use-after-free bug
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-05 23:54:49 +03:00
Cyrill Gorcunov
6b27129f80 preproc: Use nasm_zalloc helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 08:45:52 +03:00
Keith Kanios
6faad4efe0 preproc.c: fix tokenize() warnings for ignored expansion definitions 2010-12-18 14:08:02 -06:00
Keith Kanios
21d885b164 preproc.c: simplify %un[i]macro warning message 2010-12-18 12:22:21 -06:00
Keith Kanios
c98a5b4c89 preproc.c: warn/ignore when attempting to %un[i]macro an active macro 2010-12-18 12:17:31 -06:00
Keith Kanios
6a7c3e9f30 preproc.c: replace tabs with spaces on recent commits 2010-12-18 11:49:53 -06:00
Keith Kanios
9412465dc1 preproc.c: free expansion definitions as needed 2010-12-18 11:47:28 -06:00
Keith Kanios
104803de9f preproc.c: free tokens when ignoring expansion definition lines 2010-12-18 11:05:46 -06:00
Keith Kanios
ba935f2bc5 preproc.c: placate tokenize() warnings during expansion definition 2010-12-18 10:54:39 -06:00
Keith Kanios
3136d48212 preproc.c: fix handling of %? and %?? 2010-11-13 09:34:34 -06:00
Cyrill Gorcunov
eb7bf9811f Revert 29cb0bb1b3
Redundant call on nonsmart compilers doesn't
worth it in compare with two assignment operations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 23:08:14 +03:00
Cyrill Gorcunov
49e8f698fc preproc: Add dump_token helper
While being debugging some nifty problem I found
that it might be useful to produce a full dump of
tokens, in particular text of tokens.

For this reason dump_token is here just to not loose
it. It doesn't affect normal build procedure since it
requires a special -DNASM_TRACE to be passed to the
compiler. Which of course we don't in a regular
compilations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:35 +03:00
Cyrill Gorcunov
574fbf1972 preproc: Use nasm_zalloc more
To eliminate possible access into heap data

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:30 +03:00
Cyrill Gorcunov
a22e7a983c preproc: Use memset for stack allocated structure
To be on safe side

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:24 +03:00
Cyrill Gorcunov
6f38fe6cd5 preproc: inc_fopen -- set sl->next early
It's safer to init it early and be sure we not
miss anything after.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:18 +03:00
Cyrill Gorcunov
c515774a92 preproc: Use nasm_zalloc for new_ExpDef, new_ExpInv
Srink the code and make it a bit faster.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:13 +03:00
Cyrill Gorcunov
29cb0bb1b3 preproc: Use nasm_zalloc in new_Line
It's shorter

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:07 +03:00
Cyrill Gorcunov
a5aea577dd preproc.c: Get rid of tab/space mess
No change on binary level

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:43:56 +03:00
Cyrill Gorcunov
55cc4d0423 preproc: do_directive: Allocate 'Include' from zeroified-memory
If not all members of structure being allocated from
heap get initialized we better to use nasm_zalloc instead
of nasm_malloc.

For example inc gets allocated in do_directive being parially
initialized and we erroniously get mmac_depth set to some
crappy value leading to SIGSEV in result.

[ http://forum.nasm.us/index.php?topic=921.msg3257#msg3257 ]

nb: I've cleaned verror from tab/space mess while were at it

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-10 23:17:34 +03:00
H. Peter Anvin
5fa1b1f47a preproc.c: use nasm_strdup() rather than naked strdup() 2010-11-08 08:37:14 -08:00
Keith Kanios
9858cecf02 preproc.c: placate errors in OpenWatcom Compiler 2010-11-08 00:58:02 -06:00
Keith Kanios
0bae3e5ffa preproc.c: Fix OpenWatcom compiler error 2010-11-07 16:21:00 -06:00
Cyrill Gorcunov
329e9665eb preproc.c: Fix OpenWatcom compiler error
It doesn't like when we mess scope of variables
declaration.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-08 00:47:10 +03:00
Keith Kanios
b307a4f1eb preproc.c: merge from preproc-rewrite branch
pptok.dat: merge from preproc-rewrite branch
macros.pl: merge from preproc-rewrite branch
version: changed to 2.10rc2
2010-11-06 17:41:51 -05:00
Cyrill Gorcunov
6cdc900d8d preproc.c: Restore concat rules on context local variables
This is a backport of commits

8dcbbd7af0
575d4289c9

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:43:03 +04:00
Cyrill Gorcunov
0457bcbf2e preproc: Issue warning on unterminated %{ construct
As being pointed by "matching braces" topic on
[ http://forum.nasm.us/index.php?topic=905.0 ]
we don't issue warning on missed match for "{"
brace opened.

Strictly speaking we should issue error instead and
force user to fix asm source code but since it's
here for a long time already -- lets be "admissive".

Reported-by: Klod
CC: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:41:35 +04:00
Cyrill Gorcunov
71787fda1b BR3074517: Print %macro name inside %rep blocks
If we're to print inside %rep block we should find
out which %macro it belongs.

Reported-by: Rob Neff
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:40:59 +04:00
Cyrill Gorcunov
e0fdd77584 preproc: Issue warning on unterminated %{ construct
As being pointed by "matching braces" topic on
[ http://forum.nasm.us/index.php?topic=905.0 ]
we don't issue warning on missed match for "{"
brace opened.

Strictly speaking we should issue error instead and
force user to fix asm source code but since it's
here for a long time already -- lets be "admissive".

Reported-by: Klod
CC: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-07 19:42:12 +04:00