24 Commits

Author SHA1 Message Date
Stanislav Gromov
0cb9fb3ff6 Misc. minor fixes (#423)
* Misc. minor fixes

* Fix OOB array access in encode_cell()

* Fix memory leaks in plungequalifiedfile()

* Remove redundant NULL pointer checks

* Fix invalid uses of realloc()

* Remove 'do_switch()'

* Don't use 'strlen()' to identify empty strings

* Other minor fixes

* Fix incorrect error message when compression is ineffective

* Add macro 'strempty' to identify empty strings
2019-06-17 02:57:49 +02:00
Y-Less
9a16724b6a Write .lst after the second pass. (#375) 2018-10-24 10:07:00 +01:00
Zeex
16995c5ee1 Whitespace cleanup 2018-08-11 23:12:45 +06:00
Adrian Graber
0c9ddcfad1
Don't generate function preamble on naked functions 2018-07-08 18:00:15 +02:00
Zeex
892744313d
Merge pull request #255 from Daniel-Cortez/constvalue-opt
Memoize the last node in constvalue lists
2018-04-22 19:19:43 +06:00
Daniel_Cortez
9ca1b4a61e Redo constvalue list optimisation 2018-02-22 03:51:42 +07:00
Daniel_Cortez
3c252211f0 emit: Minor adjustments 2018-02-12 12:31:41 +07:00
Daniel_Cortez
a19b740a28 emit: Allow the use of labels in arguments of type 'any' 2018-02-01 02:49:59 +07:00
Daniel_Cortez
ca01cbdf7d emit: Redo instruction output 2018-02-01 02:49:58 +07:00
Daniel_Cortez
7f9be67497 emit/__emit: Change the argument order in 'outinstr()'
Now the function takes the array itself before the array size, as the argument handlers in sc1.c do.
2017-11-18 23:43:32 +07:00
Zeex
4a5e02ef29 Clean up global declarations 2017-10-28 05:05:37 +06:00
Zeex
237d89e7e4 Merge branch 'performance' of https://github.com/maddinat0r/pawn into performance 2017-10-24 08:38:47 +06:00
Zeex
a99e649a6b Group sequences of repeating literals into one write
Add a new "dumpn" pseudo-opcode that dumps N copies of the same value
to the stage buffer. It's basically the same as "dump" but much faster
when dumping the same value a lot of times, for example, when writing
initial values for large arrays.

On my Linux system the time it took to dump a 100000000 cell array went
down from 20 to 8 seconds in Release configuration, i.e. 2.5 times faster!

I haven't profiled further yet (Visual Studio 2017 profiler is broken,
gprof won't output anything (I'm probably doing it wrong), I might try
valgrind later).
2017-10-22 12:36:55 +06:00
Daniel_Cortez
aa9f589bf5 Memoize the address of the '__line' symbol instead of searching for it in loctab/glbtab every new line 2017-10-20 23:02:34 +07:00
VVWVV
e19354a52c Add new asm operator instead of #emit
Signed-off-by: VVWVV <d0u61ev@gmail.com>
2017-07-29 22:02:26 +03:00
Zeex
687d1ff017 Remove extra newlines from assembly listings
Those new lines were added in commit 6b2119f9. This is basically
an improved version of that fix.

Fixes #149.
2017-02-12 20:49:08 +06:00
Zeex
3a4878f54b Fix clang warnings 2017-02-11 19:32:10 +06:00
Zeex
8d6f051db4 Add __file, __date, __time constants
Closes #105, fixes #144.
2017-02-04 13:05:02 +06:00
Zeex
0cd10a73d6 Revert "Add built-in __file constant"
This reverts commit d15fc2224be20eac391062d1c1898b027a168713.
2017-02-03 00:45:21 +06:00
Zeex
d15fc2224b Add built-in __file constant
__file will be always set to the name of the currently processed input file.
It's similar to the __FILE__ macro in C.

See #105, #140.
2017-01-29 22:09:07 +06:00
Zeex
5cf3b0977b Add missing quotes around #file names in preprocessor output 2014-08-05 00:03:13 +07:00
Zeex
1d1244c2f0 Fix runtime error in variadic functions that return strings
This fixes a bug where returning a string from a variadic function caused
an invalid memory access error during runtime. It seems like they forgot
to update existing string return code for variadic functions.

See 11) here: http://forum.sa-mp.com/showthread.php?t=355877

--------- test code --------

native print(const s[]);

stock f(...)
{
	new a, b, c;
    new str[] = "hello";
    return str;
}

main() {
	print(f(1, 2, 3));
}

----- end of test code -----
2014-01-03 16:14:09 +07:00
Zeex
eba8474294 Fix generation of function addresses in #emit code
This fixes a bug where the compiler generated incorrect addresses for
functions in #emit code if they were defined after the point of use.

For example, you couldn't reliably get the address of a function with
"#emit CONST.pri XXX" unless you make sure that XXX is defined before
the function in which you have you are referencing it.

Now the resolution of the function's address is deferred until assembling
phase (as with CALL), and the assembler is guaranteed to see all symbols
with their final addresses. To distinguish between functions and numeric
operands I added a '.' (period) in front of function names for both #emit
and normal calls.

See also 5) here: http://forum.sa-mp.com/showthread.php?t=355877

--------- test code --------

#include <a_samp> // DO NOT REMOVE THIS

main() {
	#emit const.pri foo
}

stock foo() {
	printf("Hello, World!");
}

----- end of test code -----
2014-01-03 09:14:06 +07:00
Zeex
766b96bcf3 Lower case directory names 2013-09-19 13:06:46 +07:00