118 Commits

Author SHA1 Message Date
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
Daniel_Cortez
f5cbeb010b emit/__emit: Remove excess sc_tokens declarations, fix cell*/ucell* argument type mismatch 2017-11-12 22:54:21 +07:00
Daniel_Cortez
69b552c90d emit/__emit: Simplify the code in emit_parm2_gvar_num() 2017-11-12 20:42:19 +07:00
Daniel_Cortez
35fb9e8393 emit/__emit: Remove excess instruction name passing to emit_param_num() & emit_param_data() 2017-11-12 20:42:19 +07:00
Daniel_Cortez
d4af23b5de emit/__emit: Allow local constants to be used as data addresses in emit_param_data() 2017-11-12 19:44:52 +07:00
Daniel_Cortez
f921451c8a emit/__emit: Fix multiple occurences of NULL pointer dereference 2017-11-12 19:44:51 +07:00
VVWVV
7440670150 fix params for data seg.
Conflicts:
	source/compiler/sc1.c
2017-11-12 19:44:51 +07:00
Daniel_Cortez
eb5ee448e5 emit/__emit: Use case-sensitive search in emit_findopcode()
The instruction name is copied in lower case anyway (see emit_parse_line()).
2017-11-11 20:50:08 +07:00
Daniel_Cortez
af31143ec3 emit/__emit: Avoid excess instruction name copying in emit_findopcode() 2017-11-11 20:50:07 +07:00
Daniel_Cortez
06feab9224 emit/__emit: Code cleanup 2017-11-11 20:50:07 +07:00
Daniel_Cortez
2492d4793b emit/__emit: Set the sign bit properly on non-32-bit cells 2017-11-11 20:50:06 +07:00
Daniel_Cortez
4fc7ef863a emit/__emit: Use 'tFIRST' instead of hardcoded '256' 2017-11-11 20:50:06 +07:00
Zeex
735291fd64 Merge branch 'performance' 2017-10-28 05:18:36 +06:00
Y_Less
f1da832ae9 -E warnings as errors. 2017-10-24 21:18:07 +02:00
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