239 Commits

Author SHA1 Message Date
Y-Less
4ede5aa24f
Merge pull request #453 from Daniel-Cortez/statevar-assertion-fix
Fix assertion failure whence the script contains a single state variable
2019-11-07 01:43:08 +01:00
Y-Less
885031670a
Merge pull request #445 from Daniel-Cortez/__addrof
Operator '__addressof'
2019-11-07 01:39:52 +01:00
Y-Less
df323449ad
Merge pull request #454 from Daniel-Cortez/unnamed-enum-tags-fix
Do not allow tags inside the braces of unnamed enums
2019-11-07 01:39:27 +01:00
Y-Less
18b6df7c12
Merge branch 'dev' into __addrof 2019-11-07 01:35:51 +01:00
Amyr Ahmady
d3c0cf6bae remove emit keyword 2019-10-01 17:30:00 +03:30
Daniel_Cortez
013084e181 Fix tags being silently ignored in anonymous enums 2019-09-30 19:01:34 +07:00
Daniel_Cortez
14228a1cea Fix assertion failure with a state variable 2019-09-29 13:42:04 +07:00
Zeex
d8ac95acb8 Attempt to fix unresolved snprintf() error on Windows 2019-09-24 11:02:37 +06:00
Y_Less
fc7156241f Squashed commit of the following:
commit 448aa3b0517a48bf1eb23e143716a1d2543f0ee2
Author: Daniel_Cortez <gromovstanislav@yandex.ru>
Date:   Fri Jul 5 19:10:25 2019 +0700

    Update tests for __emit

commit b7fd80382a3481acfcb4e1335cee7071fda064f3
Author: Daniel_Cortez <gromovstanislav@yandex.ru>
Date:   Fri Jul 5 19:10:09 2019 +0700

    __emit: Do not allow pseudo-opcodes to modify constant variables/arrays
2019-09-24 00:20:09 +02:00
Y_Less
79101592e7 Squashed commit of the following:
commit b32aea5faf3cf5168cf69b1143de6b49853f0879
Author: Yashas <yashas_2010@yahoo.com>
Date:   Tue Oct 16 23:07:47 2018 +0530

    add test for issue #371

commit 66bbe6c4df3593c28fcc229b04c2be428d1da070
Author: Yashas <yashas_2010@yahoo.com>
Date:   Wed Oct 3 17:05:10 2018 +0530

    share usage information across function definitions
2019-09-23 21:54:56 +02:00
Zeex
65d6c98fc2 Fix GCC warning
source/compiler/sc1.c: In function ‘check_tagmismatch_multiple’:
source/compiler/sc1.c:3482:40: warning: ‘"’ directive writing 1 byte into a region of size between 0 and 4094 [-Wformat-overflow=]
         sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-");
                                        ^~
source/compiler/sc1.c:3482:9: note: ‘sprintf’ output 3 or more bytes (assuming 4097) into a destination of size 4095
         sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-");
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-22 17:23:26 +06:00
Daniel_Cortez
65070b6563 Allow symbols to be referenced from outside functions 2019-09-13 19:33:07 +07:00
Zeex
f8fec557e0
Merge pull request #433 from Daniel-Cortez/predef-array-fix
Fix assertion failure `glb_declared==0`
2019-07-03 14:58:11 +06:00
Daniel_Cortez
5122a99e44 Fix local variables being able to be self-assigned through initialization 2019-06-28 23:56:44 +07:00
Daniel_Cortez
ccb8980f65 Fix 'glb_declared==0' assertion failure 2019-06-23 20:02:49 +07:00
Zeex
c9b3e44bcb
Merge pull request #378 from Y-Less/Branch_pragma_nodestruct
Branch pragma nodestruct
2019-06-17 10:58:07 +06:00
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
Zeex
e645ffceef
Merge pull request #397 from Daniel-Cortez/suggestions-fix
More fixes related to suggestions
2019-06-16 12:48:26 +06:00
Daniel_Cortez
5c4e0c27a7 __emit: Fix undefined behavior
Apparently shifting a 32-bit signed value by 31 bits is UB...
2019-06-08 03:03:01 +07:00
Daniel_Cortez
8394b5a29e __emit: Make sure the opcode table is sorted 2019-06-03 17:06:31 +07:00
Daniel_Cortez
2cfcd2130b __emit: Implement pseudo-opcodes 2019-06-03 17:04:05 +07:00
Daniel_Cortez
4c260e6c60 __emit: Allow negative offsets for arguments of type 'local variable' 2019-05-04 15:53:08 +07:00
Daniel_Cortez
3c370ffde2 __emit: Fix previously undetected error case related to invalid use of the '-' sign 2019-05-04 15:51:38 +07:00
Daniel_Cortez
40dace770f __emit: Change the format of errors related to invalid use of the '-' sign
Example:
  L1:
  __emit const.pri -L1;
Before:
  error 001: expected token: "-any value-", but found "-L1"
After:
  error 001: expected token: "-any value-", but found "-(-label-)"
2019-05-04 15:50:48 +07:00
Daniel_Cortez
4b490e8ec2 Fix potential buffer overrun in #emit and __emit 2019-05-04 15:49:44 +07:00
Daniel_Cortez
62779691ab __emit: Display the type of passed-by-reference arrays in error messages as "-reference-" 2019-05-04 15:48:09 +07:00
Daniel_Cortez
86f2b783f8 __emit: Do not allow to pass references (passed by reference function arguments) to 'stor.s.pri/alt', 'inc.s', 'dec.s' and 'zero.s' 2019-04-28 18:51:44 +07:00
Daniel_Cortez
32528e701a __emit: Code cleanup 2019-04-28 18:51:27 +07:00
Daniel_Cortez
3c1ac1e911 __emit: Fix crash on attempt to reference a native 2019-04-27 23:34:59 +07:00
Daniel_Cortez
69a573ad90 __emit: Remove index check for opcodes 'lctrl' and 'sctrl' 2019-04-27 23:34:58 +07:00
Daniel_Cortez
9fb9bbb3e2 __emit: Allow expressions for arguments of type 'shift' 2019-04-27 23:34:58 +07:00
Daniel_Cortez
1ad14487a3 __emit: Take in account local symbols for arguments of type 'function' 2019-04-27 23:34:57 +07:00
Daniel_Cortez
f6c9db9269 __emit: Properly display error messages on type mismatch for arguments of type 'label' 2019-04-27 23:34:56 +07:00
Daniel_Cortez
4c798112bd __emit: Don't mark functions as uWRITTEN 2019-04-27 23:34:55 +07:00
Daniel_Cortez
e93817be09 __emit: Display proper argument type names in error messages for arguments of type 'local variable' 2019-04-27 23:34:54 +07:00
Daniel_Cortez
00e3e00327 __emit: Don't accept numeric constants for arguments of type 'data offset' 2019-04-27 23:34:53 +07:00
Daniel_Cortez
4c8d56c511 __emit: Issue an error if the stack offset/data address is not a multiple of cell size 2019-04-27 23:34:52 +07:00
Daniel_Cortez
b411e5a7bc Switch from symbol subtypes to symbol subtype flags
The new system should be more flexible as it allows to combine symbol subtypes.
2018-12-31 21:44:10 +07:00
Yashas
dadc182aba rename flgDEPRECATED to flagDEPRECATED 2018-12-25 21:02:20 +05:30
Zeex
9fed28a24b Fix char* -> unsigned char* conversion error 2018-11-18 19:08:56 +06:00
Zeex
736904b13f Fix bugs related to merging of input files
This patch fixes a couple of bugs related to passing multiple input files
to pawncc, e.g.

pawncc a.pwn b.pwn

Summary of changes:

* One of the specified input files could be deleted by the compiler because
  inpfname was overwritten while parsing the code (#file directives for
  example), but in the end of compilation it thought that inpfname was holding
  the name of the temporary file, so it deleted that file. To fix this we now
  store the temporary file's name separately (in tname).

* During the copying of input source code into a temporary file the last line
  of each input file was duplicated. For some reason feof() returnd zero,
  indicating the there was more data to read, but subsequent call to fgets()
  could not read anything, and the output buffer remained unchanged.

* Added a newline at the end of each input file.

This fixes #206.
2018-11-18 19:05:23 +06:00
Y-Less
9a16724b6a Write .lst after the second pass. (#375) 2018-10-24 10:07:00 +01:00
Y_Less
4dd38ffd82 #pragma nodestruct var, names 2018-10-04 15:27:59 +02:00
Daniel_Cortez
bc04b2ef04 Show suggestions for mistyped identifiers (#353) 2018-09-29 07:03:44 +06:00
Barnaby Keene
27bdc075b2
Revert "Check if function is naked before adding +1 for PROC opcide (#357)" (#361)
This reverts commit 6dec728efe5b8c394b4059e6845d394392c68605.
2018-09-02 18:49:49 +01:00
Adrian Graber
6dec728efe Check if function is naked before adding +1 for PROC opcide (#357) 2018-09-02 18:40:35 +01:00
Zeex
5e4da78933 Fix uninitialized variable
`enumroot` was used before initialized in declglb() when compiling
code such as tests/unused_symbol_line_gh_252.pwn.
2018-08-28 22:09:26 +06:00
Zeex
16995c5ee1 Whitespace cleanup 2018-08-11 23:12:45 +06:00
Yashas Samaga B L
df9f9fe780
Merge branch 'dev' into fix-i314 2018-08-01 19:12:25 +05:30
Yashas
ce17cff7f7 trigger destructor not implemented error
```
#include <a_samp>

forward operator~(Error:right[], size);
main() {
    new Error:e;
}
```

```
CODE 0    ; 0
;program exit point
    halt 0

    proc    ; main
    ; line 4
    ; line 5
    break    ; c
    ;$lcl e fffffffc
    push.c 0
    ;$exp
    push.pri
    push.c 1
    addr.pri fffffffc
    push.pri
    push.c 8
    call .~4000000f    ; operator~(Error:)
    pop.pri
    stack 4
    zero.pri
    retn

STKSIZE 1000
```

The compiler tries to call a non-existent function. This commit instead throws "function not implemented" error when destructor definition is missing.
2018-08-01 14:09:36 +05:30