39 Commits

Author SHA1 Message Date
Daniel_Cortez
d15c11f420 Fix OPHANDLER_CALL-related warnings issued by clang on non-x86 targets 2017-11-11 20:50:07 +07:00
Daniel_Cortez
06feab9224 emit/__emit: Code cleanup 2017-11-11 20:50:07 +07:00
Zeex
735291fd64 Merge branch 'performance' 2017-10-28 05:18:36 +06:00
Zeex
4a5e02ef29 Clean up global declarations 2017-10-28 05:05:37 +06:00
Y_Less
f1da832ae9 -E warnings as errors. 2017-10-24 21:18:07 +02:00
Zeex
237d89e7e4 Merge branch 'performance' of https://github.com/maddinat0r/pawn into performance 2017-10-24 08:38:47 +06:00
Zeex
bf514bcd7d Increase size of literal queue buffer 2017-10-23 08:00:33 +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
Daniel_Cortez
8665f8b03c Code cleanup, style fixes 2017-10-19 21:08:20 +02:00
Alex Martin
3c5f91dd0b fix symbol lookup for symbols with same name 2017-10-19 21:08:20 +02:00
Alex Martin
73d4934d61 store symbol children for faster lookup 2017-10-19 21:08:20 +02:00
Alex Martin
0138726698 add symbol lookup cache 2017-10-19 21:08:20 +02:00
Daniel_Cortez
6119df8f2b Rename asm to emit, add __emit as an alternate keyword. 2017-10-06 15:51:24 +07:00
VVWVV
ea8a77577f Fix OPHANDLER_CALL
Signed-off-by: VVWVV <d0u61ev@gmail.com>
2017-08-19 18:50:10 +03: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
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
f9e9c181dd Mark symbols as read when they are passed as function arguments
This is an improved version of the earlier fix for bug #131.

Also should fix https://github.com/Misiur/YSI-Includes/issues/154.
2017-01-28 12:59:49 +06:00
Zeex
25b21eb0aa Improve reparse check
Only reparse if the function has a tagged result (old behavior) or a
global variable is passed as one of its arguments at some point before
declaration/definition.

Also warn if need to reparse so that developers are aware of potential
performance hit.

Fixes #131.
2017-01-22 17:26:14 +06:00
Zeex
69f1ec61f9 Fix typo in constant name (DEPRICATED -> DEPRECATED) 2017-01-21 14:33:46 +06:00
Sergei Marochkin
1a608c25a1 Add -R param to enable or disable recursion report 2016-11-11 19:27:09 +03:00
Zeex
3594c6170d Fix previous fix 2015-04-26 02:06:06 +06:00
Zeex
85f849ba08 Fix symbol nesting level not remembered for 2d+ arrays
This fixes a bug where defining a 2d+ array variable in different
blocks at the same nesting level would trigger a symbol redefinition
error. For example:

main() {
	new x;

	if (x) {
		new a[10][11];
	} else {
		new a[10][12]; // error 021: symbol already defined: "a"
	}
}

It turned out that the compiler defines a separate symbol for each
of the array dimensions but it only was setting sym->compound for the
first of them, causing delete_symbols() to not delete the remaining
dimension symbols. Now it sets the compound field for all dimensions.

Fixes #60
2015-04-25 15:49:10 +06:00
Zeex
6e8bdc7438 Allow 4-dimensional arrays (experimental)
Refs #43
2015-04-13 12:23:39 +06:00
Zeex
17b5c4ffe6 Add missing declaration of pc_createtmpsrc() 2015-04-05 01:39:44 +06:00
Zeex
eeefc4ba3b Fix compile warnings 2015-04-02 15:58:00 +06:00
Zeex
49642cb2cf Revert "Fix assert failure due to signed/unsigned char mismatch"
This reverts commit a1d0fe39d488f2376b76b6b2d0a81f29b1b61dcc.

It's a total mess! I can't understand their logic on choosing signed vs.
unsigned char. I guess I'd better off not touching this at all.
2014-04-06 14:05:48 +07:00
Zeex
a1d0fe39d4 Fix assert failure due to signed/unsigned char mismatch 2014-04-06 13:57:43 +07:00
Zeex
7ee5e98e30 Introduce compatibility mode
The compiler now has a new command-line option (-Z) that toggles
between normal mode and "compatibility" mode.

When this mode is on the compiler attempts to be compatible with
the current SA-MP compiler, which allows compiling old SA-MP scripts
that would not compile otherwise and at the same time benefiting
from new features and bug fixes.

In particular, this allows compiling code that relies on the auto
generated #include guard symbols (_inc_filename).

And in case you're wondering, the Z in "-Z" does not stand for "Zeex",
it just means "a letter that is unlikely to be ever taken by another
option".

This closes #23.
2014-03-29 21:31:53 +07:00
Zeex
74625128c4 Another stringlist fix
The previous one didn't quite work with the docstring list.
2014-01-26 00:19:41 +07:00
Zeex
8a32378617 Revert "Optimize stringlist functions"
This reverts commit fba30db927355e73fd3119f3365cea3ae1e9ad2d.

Conflicts:
	source/compiler/sclist.c
2014-01-25 20:59:15 +07:00
Zeex
fba30db927 Optimize stringlist functions
The get_string() function becomes a major bottleneck (around 80% of
the time) when debug info is on because it uses a linked list for
storage and it's mostly called in for loops iterating over the whole
list by index. That's a quadratic complexity.

This patch rewrites all stringlist functions to use an array instead
of a linked list. It decreased my test script's compile time from 84s
to 10s, or by 730%(!). The script is just 100,000 lines of print()
statements. If debug info is turned off the times are the same for both
implementations.
2014-01-25 14:40:32 +07:00
Zeex
1bd6be93e0 Add #warning directive
This fixes #7.

Example:

 #warning blah blah

Result:

warning.pwn(1) : warning 237: user warning: blah blah

Pawn compiler 3.2.3664.samp	 	 	Copyright (c) 1997-2006, ITB CompuPhase

1 Warning.
2014-01-10 02:10:53 +07:00
Zeex
634f40953b Introduce #pragma warning
This pragma lets you to enable or disable a specific warning by its
unique number (same as in error messages).

Syntax: #pragma warning (push|pop|enable XXX|disable XXX)

#pragma warning push - save current warnings
#pragma warning pop - restore warnings
#pragma warning enable XXX - enable warning XXX
#pragma warning disable XXX - disable warning XXX
2014-01-05 02:58:42 +07:00
Zeex
53221dd2cc Introduce #pragma naked
When applied to a function #pragma naked merely disables the "should return
a value" warning for the function. It's intended to be used with functions
that return a value via #emit instead of the normal return statement.

This pragma works only on function definitions, not declarations. It's also
pretty stupid - the function may be defined way after this directive and it
won't stop on things coming in between.

For example, here all declarations between #pragma naked and f() are
effectively ignored:

#pragma naked

new x;       // ignored
forward g(); // ignored
native n();  // ignored

f() {
    // f() becomes naked
}

Note that #pragma naked does not affect generated code in any way, unlike
e.g. __declspec(naked) or __attribute__((naked)) in C/C++ where the compiler
omits the code for the prolog and epilog.
2014-01-05 01:26:10 +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
766b96bcf3 Lower case directory names 2013-09-19 13:06:46 +07:00