239 Commits

Author SHA1 Message Date
Yashas
ad4ad64a8b check dimensions of uninitialized array declarations
Fix for #314
2018-07-29 16:15:37 +05:30
Barnaby Keene
e9e61ec751
Merge pull request #328 from YashasSamaga/fix-i276
fix various issues associated with i276 and pr302
2018-07-27 08:01:18 +01:00
Adrian Graber
0c9ddcfad1
Don't generate function preamble on naked functions 2018-07-08 18:00:15 +02:00
Yashas
ffb161ad95 check array depends for modifications for W214 2018-07-08 12:04:38 +05:30
Yashas
116ec5f0fd mark array arguments of public functions modified
The arguments of public functions are marked as READ by default to prevent 203/204 warnings.

The reason is probably that there is no requirement imposed by the host on the user that they read all the arguments.

Smilarly the array/reference arguments need not be modified but the forward takes both cases into consideration.

This prevents warning 214 on array arguments of public functions.
2018-07-08 12:04:38 +05:30
Y_Less
836d4d9e35 Fix #317 2018-06-16 09:53:14 +01:00
Zeex
537c91ab91
Merge pull request #302 from YashasSamaga/fix-i276
suggest `const` qualifier for arguments and inform user when an array/string literal is passed as a non-const argument
2018-06-03 03:36:05 +06:00
Yashas
29669858b3 enable warning 214
warning 214: possibly a "const" array argument was intended:
2018-05-10 09:45:10 +05:30
Yashas
fd4369e67b debug info for index tagmm warnings
This commit makes the compiler display debug information for "index" tag mismatch warnings.
2018-05-08 09:43:34 +05:30
Zeex
fd31205957 Merge branch 'destructors-fix' of https://github.com/YashasSamaga/pawn 2018-04-24 15:20:19 +06:00
Zeex
c6246027f3 Merge branch 'fix-i262' of https://github.com/YashasSamaga/pawn 2018-04-22 19:43:37 +06:00
Zeex
70da4e12ef Make #pragma option also update builtin constants
If you used #pragma option -d3 or #pragma option -Z the corresponding
constants (debug and __compat respectively) were not updated; now the
are.

Fixes #253.
2018-04-22 19:39:13 +06: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
Zeex
f52bed7043
Merge pull request #279 from Daniel-Cortez/emit-patch1
Another bunch of fixes/improvements for 'emit'
2018-04-22 19:13:57 +06:00
Zeex
1fbc474543 Merge branch 'improvement-i172' of https://github.com/YashasSamaga/pawn 2018-04-22 19:12:28 +06:00
Daniel_Cortez
9ca1b4a61e Redo constvalue list optimisation 2018-02-22 03:51:42 +07:00
Daniel_Cortez
900043e695 emit: Apply 'integer value' type to the argument of 'jrel' 2018-02-12 12:31:45 +07:00
Daniel_Cortez
1dac1a2d70 emit: Make the compiler tell it expects "any value" for arguments of type 'any' 2018-02-12 12:31:44 +07:00
Daniel_Cortez
b0026d8ce6 emit: Check if the argument of 'align.pri/alt' is in range from 0 to (sizeof(cell)-1) 2018-02-12 12:31:43 +07:00
Daniel_Cortez
78f6959630 emit: Change the argument type in 'lidx.b' and 'idxaddr.b' to 'shift' 2018-02-12 12:31:43 +07:00
Daniel_Cortez
7a0e966edf emit: Add new argument type: 'integer value' 2018-02-12 12:31:42 +07:00
Daniel_Cortez
3c252211f0 emit: Minor adjustments 2018-02-12 12:31:41 +07:00
Daniel_Cortez
eb4f6ea624 emit: Remove duplicate code from 'emit_param_index()' and 'emit_param_nonneg()', reuse the code from 'emit_param_any()' instead 2018-02-07 19:30:03 +07:00
Daniel_Cortez
05de997b00 emit: Add optional ':' prefix for labels as instruction arguments 2018-02-07 19:30:02 +07:00
Daniel_Cortez
7de402d997 emit: Fix "extra characters on line" error on single-line 'emit{}' statements 2018-02-04 00:54:01 +07:00
Daniel_Cortez
fdae3827f2 emit: Minor fixes/adjustments 2018-02-01 03:11:31 +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
bc76324d03 emit: Check if the argument of 'shl.c.pri/alt' and 'shr.c.pri/alt' is in range from 0 to (sizeof(cell)*8-1) 2018-02-01 02:49:59 +07:00
Daniel_Cortez
f0a1d3ead0 emit: Add new argument type: 'non-negative integer' 2018-02-01 02:49:58 +07:00
Daniel_Cortez
ca01cbdf7d emit: Redo instruction output 2018-02-01 02:49:58 +07:00
Daniel_Cortez
4f099e7eb1 emit: Disallow the use of the '-' sign with function names for arguments of type 'any' 2018-02-01 02:49:58 +07:00
Southclaws
0f5007c538
Merge pull request #270 from YashasSamaga/fix-i254
trigger unused symbol warning for references
2018-01-28 12:45:44 +00:00
Yashas
43c4a5f18b user friendly tagmm warnings 2018-01-25 23:18:17 +05:30
Yashas
a7d7cf85e3 trigger unused symbol warning for references
If a reference argument is not read within the function, the compiler does not trigger an unused symbol warning.

This commit modifies the compiler to trigger warnings in such cases.

Notes:
I spent some time checking through every reference that was made to the `uREAD` flag in the entire codebase. As far as I could see, there would be no side-effects of this commit.
2018-01-19 22:01:06 +05:30
Yashas
1d60153af1 don't do implicit return tasks in naked functions
This commits prevents the compiler from calling destructors and adding the return instructions implicitly in naked functions.
2018-01-18 23:58:18 +05:30
Yashas
345b415d55 debug info for tagmismatch warnings
This commit adds useful information to the "tag mismatch" warning.
2018-01-18 21:41:26 +05:30
Yashas
0ecffcb834 corrected formatting of code 2018-01-15 01:43:25 +05:30
Yashas
39ec842130 corrects behaviour of md-array destructor calls
Currently, the destructors are triggered for each indirection level of the multi-dimensional array. The PAWN Implementer Guide states that the destructor must be triggered for the actual data only.

Apart from the above correction, this commit also fixes a typo which caused wrong sizes to be passed to the destructor.
2018-01-15 01:24:10 +05:30
Yashas
8fd46af2ec prevent destructor calls for static locals 2018-01-15 00:21:37 +05:30
Yashas
87d718f12c call destructors on implicit return
The destructors for local variables were not being called when the function returns without the user expclitly giving a return statement.

This commit adds code to call the destructors for the local variables on an implicit return.
2018-01-14 13:12:55 +05:30
Yashas
57ef6150ed warning for meaningless class combinations
1. Adds a generic new warning which is triggered when meaningless combination of class specifiers are used.

2. This commit adds code to trigger a warning for the following two cases:
- constant reference
- - not meaningful as as references always point to cells in PAWN (unlike C++ where it would help costly copies while guaranteeing to not modify the object) which makes const reference is as good as pass-by-value
- constant variable arguments
- - for similar reasons as in the previous case
2018-01-12 23:51:35 +05:30
Daniel_Cortez
30e1ef9389 Memoize the last node in constvalue lists 2018-01-12 23:30:04 +07:00
Zeex
9a21fb5a2f Reset errline to -1 instead of 0 2018-01-12 20:33:17 +06:00
Zeex
05582c8c0d Show correct line for unused symbol warning for global symbols
Fixes #252.
2018-01-10 20:53:34 +06:00
Southclaws
a47bd9de76
Merge pull request #240 from Daniel-Cortez/ht-patch
New hashtable implementation
2018-01-07 12:45:40 +00:00
Zeex
3c6be803d7 Fix errline not being reset after it's set to symbol line
Fixes #230.
2018-01-07 12:14:55 +06:00
Daniel_Cortez
8b3583e7b5 Replace the hashmap implementation with a hashtable by Mattias Gustavsson 2018-01-07 02:35:08 +07:00
Zeex
6d65605bb0 Decrease initial size of symbol cache hash table
Using 2^23 allocates 128MB memory for the hash table. Seems like
a waste of memory, especially for small scripts.

For example, I didn't notice a huge difference in time between 1000
and the old number when compiling most of YSI includes and tests.
Hash tables double in size when they need more space, it's pretty
efficient (at least this implementation does so).
2018-01-06 10:18:47 +06:00
Yashas
19a8bfd1f3
replaces dangling pointers in initarray with indexes
In `initarray`, `prev1` and `prev2` are dangling pointers. When assigned, they point to an address of an item in the literal queue. The compiler checks the literal queue size before adding an element. If the size isn't sufficient to hold another element, it reallocates the literal queue to accommodate more items. When the reallocation happens, the previous references (`prev1` and `prev2`) to the elements of the literal queue are invalidated. De-referencing the broken pointers will cause undefined behavior.

This commit replaces the pointers with indexes. The indexes are invariant to the reallocation.
2017-12-31 18:30:06 +05:30
Zeex
11199da210 Fix compile warnings in pawnc 2017-12-30 16:12:33 +06:00