139 Commits

Author SHA1 Message Date
Y-Less
18b6df7c12
Merge branch 'dev' into __addrof 2019-11-07 01:35:51 +01:00
Amyr Ahmady
51fdf6f825 a simpler fix for '#pragma option' 2019-10-07 15:59:01 +03:30
Amyr Ahmady
ff162b3e2e check if 'i' is '32' for texts with less than 31 characters 2019-10-07 15:23:58 +03:30
Amyr Ahmady
b8dbbe9e43 fix "#pragma option" crash when character count is over 31
For some reason `i` will be `32` after our for loop so an OOB happens when code tries to assign `'\0'` to `name[32]` since `name` size is 32.
Doing a `-1` to `i` fixed this issue and now throws `error 038: extra characters on line` when character count is over 31.
2019-10-07 11:12:59 +03:30
Amyr Ahmady
d3c0cf6bae remove emit keyword 2019-10-01 17:30:00 +03:30
Daniel_Cortez
1d3b2319fd Implement operator '__addressof' 2019-09-18 19:50:28 +07:00
Daniel_Cortez
65070b6563 Allow symbols to be referenced from outside functions 2019-09-13 19:33:07 +07:00
Zeex
cf4b65ca66 Reset literal queue after unknown preprocessor directive
Fix an assertion failure at sc1.c:3702 (litidx==0).
2019-06-29 20:32:54 +06:00
Zeex
b2eca9203b
Merge pull request #427 from Y-Less/Branch_ignored_directives
Ignore `#if`d out unknown directives.
2019-06-29 20:29:56 +06:00
Zeex
c9b3e44bcb
Merge pull request #378 from Y-Less/Branch_pragma_nodestruct
Branch pragma nodestruct
2019-06-17 10:58:07 +06:00
Zeex
599415444b
Merge pull request #377 from Y-Less/Branch_pragma_unwritten
Branch pragma unwritten
2019-06-17 10:56:39 +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
Y_Less
267c8f8ffd Ignore #ifd out unknown directives.
Makes the compiler slightly more future-proof by allowing us to do something like:

```pawn
#if __Pawn >= 0x03AB
    #message You're on a nice new compiler.
#endif
```

Currently to do that you need to do:

```pawnc
#message You're on a nice new compiler.
```

```pawn
#if __Pawn >= 0x03AB
    #include "message.inc"
#endif
```

Or you get an error that `#message` (or anything else) is an unknown directive if the compiler doesn't recognise it, even if it is disabled.

The only downside to this is that it makes it slightly harder to add new `#if`-like directives:

```pawn
#if __Pawn >= 0x03AB
    #message You're on a nice new compiler.
#elif SHOW_ERROR
    #error You've got an error.
#endif
```

A compiler that fails the first check AND doesn't recognise `#elif` will simply skip it and go all the way to `#endif`.  It will not evaluate it as `#elseif` and potentially run the code within.  It should somehow recognise `#elif` as a `#if`-like directive it just doesn't know and give an error.  That would require some sort of hard convention we don't yet have.  That, or we just define all possible ones now (even if they aren't implemented):

```pawn
#if
#else
#elseif
#elif
#ifdef
#elifdef
#elseifdef
#endif
#fi
#el
#ifndef
#elseifndef
#elifndef
```

Can't think of any more, but that doesn't mean there aren't any (does `iff` make any sense here?)
2019-06-16 02:40:17 +02: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
4b490e8ec2 Fix potential buffer overrun in #emit and __emit 2019-05-04 15:49:44 +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
Yashas
797fdfc06b Revert "force sc_tokens size and token enumeration size to match"
This reverts commit d60ef405c9f3eca13dd7e505c8c330ec0241ff02.
2019-01-19 13:29:00 +05:30
Yashas
d60ef405c9 force sc_tokens size and token enumeration size to match 2018-12-31 10:34:38 +05:30
Yashas
01c2dcaeb4 change tINCLUDE to toINCLUDE 2018-12-25 21:03:44 +05:30
Yashas
a9970bb452 remove the unused tDBLCOLON token 2018-12-25 20:59:51 +05:30
Y-Less
9a16724b6a Write .lst after the second pass. (#375) 2018-10-24 10:07:00 +01:00
Y_Less
e9d61e29f5 #pragma unwritten and #pragma unread. 2018-10-04 15:30:50 +02:00
Y_Less
4dd38ffd82 #pragma nodestruct var, names 2018-10-04 15:27:59 +02:00
spacemud
35fa8d4485 Fix empty warnings causing crashes (#369)
* Fix empty warnings causing crashes

* Add tests

...fix tests
2018-10-04 06:56:29 +01:00
Zeex
16995c5ee1 Whitespace cleanup 2018-08-11 23:12:45 +06:00
Y_Less
000b4d52b9 Cast error on mac.
Yet again fixing the tests...
2018-06-30 17:32:53 +02:00
Y_Less
23485cfeda Allow line continuations in single-line comments only when they are followed by another comment:
It is quite annoying to get an error for commenting out a define using:

//
// #define LONG_MACRO\
//             did span \
//             multiple lines
//
2018-06-30 17:03:36 +02:00
Y_Less
62805cb400 Redetect error 49, and make deprecated auto-insert spaces. 2018-06-30 16:47:47 +02:00
Y_Less
9136cf2946 Partially revert #c325ca3e028388ae6f934df2a4057229d24d021e to strip spaces in strings again. 2018-06-30 16:41:50 +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
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
Daniel_Cortez
9ca1b4a61e Redo constvalue list optimisation 2018-02-22 03:51:42 +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
Zeex
73b64e141f Fix crash when #pragma deprecated message is empty
Fixes #283.
2018-02-08 07:39:07 +06:00
Daniel_Cortez
f0a1d3ead0 emit: Add new argument type: 'non-negative integer' 2018-02-01 02:49:58 +07:00
Southclaws
a47bd9de76
Merge pull request #240 from Daniel-Cortez/ht-patch
New hashtable implementation
2018-01-07 12:45:40 +00:00
Zeex
76507598f8 Refactor #warning and #pragma deprecated 2018-01-07 12:14:58 +06:00
Daniel_Cortez
d514b99760 Fix a type conversion warning 2018-01-07 04:21:13 +07:00
Daniel_Cortez
8b3583e7b5 Replace the hashmap implementation with a hashtable by Mattias Gustavsson 2018-01-07 02:35:08 +07:00
Zeex
c325ca3e02 Implement more straightforward line continuation ('\\') behavior
* Allow line continuation in single line comments

  Other languages allow this:

  // this is totally a single \
  line comment

  For example C++, at least GCC, Visual C++. I don't see why it
  should be forbidden.

* Don't insert \a symbols to mark

  Because we now don't need to check if there are '\\' in comments
  we no longer have to mark their positions with '\a' symbols.

* Don't trim leading space after '\\'

  Again, this is how other languages do it and it seems to be more
  intuitive. If you don't want spaces just don't indent your lines.

  new s[] = "see \
  this?"
2018-01-04 17:38:13 +06:00
Yashas
9a49ac51b2
stop removing '\a (internal multi-line delimiter)
This reverts a part of 693591bdc3 which caused issues as described in #226.
2018-01-03 18:09:54 +05:30
Zeex
4d1a3a99f7 Revert "Merge pull request #205 from VVWVV/concat_op"
This reverts commit 82dd745f90b9447ac2f196c31642660a7488453f, reversing
changes made to 2a930cedde954831eebee1a221a297e1019cb4df.
2017-12-31 18:27:58 +06:00
Zeex
11199da210 Fix compile warnings in pawnc 2017-12-30 16:12:33 +06:00
Zeex
82dd745f90
Merge pull request #205 from VVWVV/concat_op
Tokenisation operator
2017-12-30 15:15:28 +06:00
Zeex
064d35256b
Merge pull request #211 from Daniel-Cortez/emit_op_fixes
Fixes and improvements for emit/__emit
2017-12-30 15:00:52 +06:00
Daniel_Cortez
912376b658 emit/__emit: Check if the argument of instruction 'call' is a Pawn function 2017-11-17 20:03:50 +07:00
Daniel_Cortez
abe9c965dc emit/__emit: Make type mismatch errors more informative
Example:
    main()
    {
        new x;
        emit load.pri x
    }
Before this commit:
    error 017: undefined symbol "x"
After:
    error 001: expected token: "-data offset-", but found "-local variable-"
2017-11-17 20:03:50 +07:00
Daniel_Cortez
28c69cd8c8 #emit: Set the sign bit properly on non-32-bit cells 2017-11-12 19:44:51 +07:00
VVWVV
f59b285e17 fix ppconcat function 2017-11-04 00:05:54 +03:00
Y_Less
6060ce0ac8 Merge branch 'master' of github.com:Zeex/pawn 2017-10-28 14:40:58 +02:00