156 Commits

Author SHA1 Message Date
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
345b415d55 debug info for tagmismatch warnings
This commit adds useful information to the "tag mismatch" warning.
2018-01-18 21:41:26 +05:30
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
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
Zeex
0533717bd6
Merge pull request #215 from Daniel-Cortez/lbl_redef_fix
Do not allow to redefine labels
2017-12-17 13:57:33 +06:00
Daniel_Cortez
939c06011d emit/__emit: Another syntax change 2017-12-10 03:51:19 +07:00
Daniel_Cortez
54fd3aee3a emit/__emit: Add fallbacks for the other macro opcodes 2017-12-06 22:39:37 +07:00
Daniel_Cortez
9fbe72ee7a emit/__emit: Implement compatibility fallbacks for 'sysreq.c' and 'sysreq.n' 2017-12-06 21:52:51 +07:00
Daniel_Cortez
d5691209d6 emit/__emit: Move the "anti-optimisation" workaround to 'emit_parse_line()'
Conflicts:
	source/compiler/sc1.c
2017-12-06 21:52:51 +07:00
Daniel_Cortez
59428b0c39 emit/__emit: Code cleanup, misc. adjustments 2017-12-06 17:42:30 +07:00
Daniel_Cortez
c77b0f1bdd emit/__emit: Verify the arguments for 'sysreq.c' and 'sysreq.n' 2017-12-06 17:42:26 +07:00
Daniel_Cortez
bd01c04def emit/__emit: Fix argument type for 'addr.pri/alt' 2017-12-04 22:43:40 +07:00
Daniel_Cortez
5f716b7f62 emit/__emit: Don't allow to use labels as arguments of type 'numeric value', 'data offset', 'local variable' and 'function' 2017-12-04 21:38:09 +07:00
Daniel_Cortez
e922e48aa6 emit/__emit: Fix incorrect code generation 2017-12-04 18:24:32 +07:00
Daniel_Cortez
fab8c53db0 emit/__emit: Allow the use of constant expressions as opcode arguments 2017-12-03 21:27:16 +07:00
Daniel_Cortez
401b29f464 Do not allow to redefine the same label 2017-12-02 20:16:45 +07:00
Daniel_Cortez
873060e7e8 emit/__emit: Do not allow to redefine the same label 2017-12-02 20:12:20 +07:00
Daniel_Cortez
907c4b610e emit/__emit: Syntax change 2017-11-29 21:52:05 +07:00
Daniel_Cortez
afc829977e emit/__emit: Add support for 'lctrl 8/9' and 'sctrl 8/9' 2017-11-23 22:41:14 +07:00
Daniel_Cortez
23ab402763 emit/__emit: Fix argument handling in 'const.s' 2017-11-19 16:17:20 +07:00
Daniel_Cortez
40bf47c6b5 emit/__emit: Allow direct use of opcode 'casetbl' 2017-11-19 02:44:45 +07:00
Daniel_Cortez
b52e32d1bc emit/__emit: Move 'fetchlab()' closer to 'dogoto()' and 'dolabel()' 2017-11-19 02:44:45 +07:00
Daniel_Cortez
7f9be67497 emit/__emit: Change the argument order in 'outinstr()'
Now the function takes the array itself before the array size, as the argument handlers in sc1.c do.
2017-11-18 23:43:32 +07:00
Daniel_Cortez
60ca0009f3 emit/__emit: Also check the arguments of 'lctrl' and 'sctrl' 2017-11-18 01:37:03 +07:00
Daniel_Cortez
15e53272af emit/__emit: Allow named constants with 'lodb.i' and 'strb.i' 2017-11-18 01:37:03 +07:00
Daniel_Cortez
98817bf8f8 emit/__emit: Code cleanup, minor fixes 2017-11-18 01:37:02 +07:00
Daniel_Cortez
5c0d45aab3 emit/__emit: emit_param_data(): make sure the argument is not a function 2017-11-18 01:37:02 +07:00
Daniel_Cortez
5eb18c4eec emit/__emit: Allow for leading '-' to negate symbol values in emit_param_num()
Now it should be possible to do this:
    const SOME_VAL = 1;
    emit const.pri -SOME_VAL

or this:
    static some_array[] = { 0, 1, 2, 3, 4, 5 };
    static some_var;
    emit { const.pri some_var };
    new some_var_offset = emit { add.c -some_array };
2017-11-18 01:37:02 +07: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
c58fce34cb emit/__emit: New argument type: local variable (name or offset) 2017-11-14 19:36:12 +07:00
Daniel_Cortez
e55f6a213a emit/__emit: Minor adjustments 2017-11-14 19:36:11 +07:00
Daniel_Cortez
c14186a48f emit/__emit: Fix 'need_token' argument being unused in emit_invalid_token() 2017-11-14 19:36:11 +07:00
Daniel_Cortez
cccf0f1674 emit/__emit: Remove check_empty() from sc1.c
It was copied from sc2.c with a check for a trailing '}' added and was too specific to be reused anywhere else.
2017-11-13 22:52:33 +07:00
Daniel_Cortez
d788eeaeb8 emit/__emit: Make 'switch', 'casetbl' and 'case' generate valid code
This changes the way 'switch', 'casetbl' and 'case' are handled; now 'casetbl' can't be used directly and the arguments for the first case table entry (the number of entries and 'default' label) are specified to 'switch'.
Example:
    emit
    {
        load.s.pri my_var
        switch 3 lbl_deafult
        case 0 lbl_0
        case 2 lbl_2
        case 4 lbl_4
    }
2017-11-13 21:09:46 +07:00
Daniel_Cortez
b726f44a02 emit/__emit: Simplify the code in emit_parm1_lbl() and emit_do_case() 2017-11-12 22:54:21 +07:00