239 Commits

Author SHA1 Message Date
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
Alex Martin
7363feb612 change hashmap size 2017-10-19 21:08:20 +02:00
Daniel_Cortez
8665f8b03c Code cleanup, style fixes 2017-10-19 21:08:20 +02:00
Alex Martin
9efca3a7b4 increase hashmap size 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
Zeex
8b8f8adbb5 Merge pull request #189 from YashasSamaga/i159-fix
fixes deletion of constants passed a compiler args during parse
2017-10-07 22:49:28 +06:00
Zeex
0fab187aad Merge pull request #185 from Y-Less/master
Document correct state transition target name.
2017-10-07 22:48:14 +06:00
Daniel_Cortez
6119df8f2b Rename asm to emit, add __emit as an alternate keyword. 2017-10-06 15:51:24 +07:00
Y_Less
0a43faba00 Document correct state transition target name. 2017-09-10 14:46:12 +01: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
9109958fd1 Merge remote-tracking branch 'yashas/i117-fix' into master 2017-05-01 10:50:20 +06:00
Zeex
f1fec75bf4 Merge remote-tracking branch 'yashas/i84-fix' into master 2017-05-01 10:38:08 +06:00
Yashas
854e3e0296 fixes deletion of constants passed a compiler args during parse 2017-03-24 10:59:58 +05:30
Yashas
17d392b104 fixes memory corruption with multi-dimensional arrays
static const Test[2][][2] = { { { 9, 8 } },  { { 6, 7 } } };

The above code causes a memory corruption as the compiler does not
correctly calculate the size of the array.

This commit adds code to fix it.
2017-02-13 13:00:40 +05:30
Yashas
d9fff2d52a fixes multi-dimesional array initilization bug
Solves the bug described in issue #117

new [][2][3] = { //default values };
The compiler does not create enough room for the indirection tables and
hence adjust_indirectiontables overwrites the default values leaving the
array wrongly initilized.

Adds a generic code which works for any n-dimensional arrays (n = 1,
2,3,4,5... infinity). The code fixes the issue for any dimension but the
number of dimensions is limited to 4 (sDIMEN_MAX). A review of this code
won't be required if the limit is increased in the future.
2017-02-13 10:54:16 +05:30
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
Double V
7c81e6573d Fix some errors with static enums in a block (#141)
Signed-off-by: VVWVV <d0u61ev@gmail.com>
2017-01-30 00:20:46 +07: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
2dd0e8c6af Merge branch 'feature_enum_static' of https://github.com/VVWVV/pawn into VVWVV-feature_enum_static 2017-01-29 02:46:59 +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
VVWVV
0dd5a652aa Add support of 'static enum' and 'enum static'
Signed-off-by: VVWVV <d0u61ev@gmail.com>
2017-01-23 18:24:52 +03:00
VVWVV
6d2aa15a3f #134: Proposal: enum limited to single file scope
Signed-off-by: VVWVV <d0u61ev@gmail.com>
2017-01-23 14:20:33 +03: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
f96f3b978b Include build number in version and __PawnBuild constant
__PawnBuild holds the currnt build number. This allows you to detect
which compiler version is used more precisely.

It will be set to 1 on next release and incremented on each subsequent
release.

Closes #132.
2017-01-22 02:24:28 +06:00
Zeex
5bedccc36d Force a reparse if function is used before declared
Fixes #131.
2017-01-22 02:09:18 +06:00
Zeex
69f1ec61f9 Fix typo in constant name (DEPRICATED -> DEPRECATED) 2017-01-21 14:33:46 +06:00
Yashas
602178a0b5 public variables behaviour
stops unused warnings from being triggered for public variables
2016-12-26 21:30:32 +05:30
Sergei Marochkin
1a608c25a1 Add -R param to enable or disable recursion report 2016-11-11 19:27:09 +03:00
Sergei Marochkin
56ef450a24 Add detailed recursion report with call chains
Applied path from https://github.com/Zeex/pawn/tree/recursion branch.

Example:

f1() {
	f2();
}

f2() {
	f3();
}

f3() {
	f4();
}

f4() {
	f1();
}

will output:

recursion detected: function f1 indirectly calls itself:
f1 <- f4 <- f3 <- f2 <- f1
recursion detected: function f2 indirectly calls itself:
f2 <- f1 <- f4 <- f3 <- f2
recursion detected: function f3 indirectly calls itself:
f3 <- f2 <- f1 <- f4 <- f3
recursion detected: function f4 indirectly calls itself:
f4 <- f3 <- f2 <- f1 <- f4
2016-10-25 06:32:03 +03:00
Zeex
ffd4d9e98f Fix unused chdir() result value warning 2016-07-03 02:16:49 +06:00
Zeex
839cf52206 Fix missing #include <unistd.h> on Linux 2016-07-02 19:59:26 +06:00
Zeex
82ca375152 Open options file in binary mode
This fixes a gcc compile warning introduced by commit 1b0feaf3.
2016-07-02 19:57:46 +06:00
Zeex
48800fc738 Revert "Remove dubious file size check"
This reverts commit 1b0feaf380e1714ec3c15d10872b7861e420b5d0.
2016-07-02 19:44:12 +06:00
Zeex
1b0feaf380 Remove dubious file size check
As the comment right above those lines states, fread() may return a value
less than the actual file size beacuse of text conversion done by the
system. So why do it?

This fixes a bug on Windows where the compiler couldn't read the contents
of pawn.cfg because of this check. Interestingly enough, it could read the
source files just fine.

Fixes #90
2016-07-02 11:57:48 +06:00
Zeex
01609471e1 Fix inpfname being used before initialized 2016-07-02 11:52:38 +06:00
Zeex
632ab70605 Make -D option available on all platforms
Fixes #80
2016-01-10 14:31:30 +06:00
Zeex
b261bacfa4 Revert "Fix error when static/stock/public constant used as array size"
This reverts commit 39828f23f2967e78a2f0f981cbfa81e777adbef7.

Conflicts:
	source/compiler/sc1.c
2015-06-23 21:44:02 +06:00
Zeex
d8f824357f Don't remove unused public variables
But still warn about them unless they are marked as stock.

Fixes #71
2015-06-20 16:58:11 +06:00
Zeex
88f78aa882 Don't declare public constants as constants
Public constants must be declared as variables, like it was done
before the previous commit, because they must be visible by the
amx_XXXPubVar API.
2015-06-20 10:01:37 +06:00
Zeex
39828f23f2 Fix error when static/stock/public constant used as array size
Fixes #70

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

native printf(const format[], ...);

static const a = 1;
static stock const b = 2;
stock const c = 3;
public const d = 4;

main() {
	static const e = 5;
	new aa[a];
	new ab[b];
	new ac[c];
	new ad[d];
	new ae[e];
	printf("%d", sizeof(aa), aa);
	printf("%d", sizeof(ab), ab);
	printf("%d", sizeof(ac), ac);
	printf("%d", sizeof(ad), ad);
	printf("%d", sizeof(ae), ae);
}

----- end of test code -----
2015-06-19 21:49:40 +06:00
Zeex
1cca8af0d2 Fix indirection vector calculation
It was broken in commit d14f4870a8069ca446c0528a39b75e7d081ba3d5.

Fixes #63
2015-05-09 13:00:16 +06:00
Zeex
56262f42cd Fix compile warning 2015-05-03 01:34:00 +06:00
Zeex
d14f4870a8 Fix 4d array initialization
adjust_indirectiontables() generated wrong values for certain array
dimensions in 4d arrays.

Fixes #43
2015-05-01 16:16:59 +06:00
Zeex
10a021b51e Tiny consistency fix 2015-05-01 09:40:40 +06:00
Zeex
3594c6170d Fix previous fix 2015-04-26 02:06:06 +06:00