Nicolas Hake
a0c9bfd931
Aul: Correctly check for enable/disable keywords in warning pragma
...
The parser was only checking that the passed setting matched the
beginning of the expected keyword, instead of checking for the full
length. This way, users could write "#warning e" instead of the
expected "#warning enable" and still have it work.
2019-02-17 11:58:03 +01:00
Nicolas Hake
c8d22e321b
Aul: Throw correct exception on parameter-less warning pragma
...
When no parameter followed the "#warning" pragma, because the end
iterator would be located before the begin iterator, basic_string's
constructor would throw std::length_error. Check for this case
beforehand so we can throw the expected C4ParseError instead.
2019-02-17 11:58:03 +01:00
Lukas Werling
cd2b8370da
Fix warnings in DirectExec crashing ( #1990 )
2018-02-04 12:33:58 +01:00
Tushar Maheshwari
3a4f49ad90
Revisit #includes
...
Consolidate the include statements scattered across the code in accordance
with the comment in C4Include.h. The advantages are listed in the same
comment.
Furthermore, it follows llvm-include-order which is the logical
extrapolation of the project's style guideline wherever possible
(C4Include.h being the most-frequent exception).
2017-05-15 13:24:59 +02:00
Tushar Maheshwari
e58a7884e4
Automatic fixes using clang-tidy
...
See http://forum.openclonk.org/topic_show.pl?tid=3376 for discussion.
Close GH-41
2017-05-03 20:30:45 +02:00
Nicolas Hake
ed193a0715
Aul: use %u instead of %zu for parameter indexes
...
MinGW uses an ancient version of the CRT, which doesn't support the z
modifier for integer types in printf. Use %u instead and cast to
unsigned.
2017-03-14 00:45:27 +01:00
Nicolas Hake
30c5bb5f8d
Aul: Allow the user to selectively enable/disable warnings
...
This commit introduces a new Aul directive "#warning", which can be used
to enable or disable warnings for a particular piece of code.
"#warning enable" enables all warnings.
"#warning disable" disables all warnings.
"#warning enable empty_parameter_in_call" selectively enables one
specific warning while not affecting any other.
All warnings that used to be controlled by Developer.ExtraWarnings
remain disabled by default.
2017-02-13 15:07:50 +01:00
Nicolas Hake
a026bda561
Aul: Let error handler count warnings and prepend severity
...
Instead of explicitly writing to the log, let C4AulParse and
C4ScriptHost warnings go to the error handler to do with as it sees fit.
2017-02-13 15:07:50 +01:00
Sven Eberhardt
1e52ed5a74
Remove unused variable ndx in C4AulParse::Parse_Expression
2016-11-10 21:43:41 -05:00
Sven Eberhardt
ebda8193ef
Replace NULL by nullptr in C++ sources
...
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Lukas Werling
9c98227a03
Fix all -Wformat warnings
2016-10-31 23:39:45 +01:00
Nicolas Hake
f0f50ec402
Aul: Don't prepend "ERROR:" to parser error msgs
...
Further formatting of the error message should be the error handler's
job.
2016-10-31 11:16:14 +01:00
Nicolas Hake
118961d0b7
Aul: fix octal escape parsing
...
Bet you didn't know C4Script supported octal escapes inside strings.
Well, it didn't; or at least not correctly.
2016-10-20 16:53:23 +02:00
Nicolas Hake
021a6e89f5
Implement direct execution of whole function definitions
...
This implements the changes made in c6e4bfd
on the AST-based parser.
2016-10-19 14:20:47 +02:00
Nicolas Hake
9caaf1e298
Aul: Split out error handling into a separate class for easier testing
...
By using an extern error handler in the script engine, we can mock that
handler and make sure something that should fail actually does, instead
of having to parse log messages.
2016-10-19 14:20:41 +02:00
Nicolas Hake
eca8f2cce8
Aul: && returns either parameter, not bool
2016-05-13 16:20:17 +02:00
Nicolas Hake
43c6f946dd
Aul: Split assignment op from standard BinOp
...
Assignment was special-cased everywhere, so it can just as well get a
separate AST node.
2016-05-13 13:50:29 +02:00
Nicolas Hake
daf3424e63
Delete some commented-out legacy function parameters
2016-05-13 13:14:23 +02:00
Nicolas Hake
092a23c2f7
Aul: Parse scripts into an AST, then generate bytecode from that
...
This commit contains a fairly substantial rewrite of the C4Script code
generator. Instead of generating bytecode while parsing the script,
we're now parsing the script into a syntax tree, and have any further
processing happen on that instead of the raw source.
At this time, the code generator emits the same bytecode as the old
parser; there are several optimization opportunities that arise from the
new possibility to emit code out of order from its specification by the
author.
Compared to the old compiler, this one is still rather deficient when
dealing with incorrect code; it's also not emitting several warnings
that used to be diagnosed.
2016-05-12 19:43:48 +02:00
Nicolas Hake
10abb1bbdb
Remove unused C4AUL_CodeBufSize
2016-05-11 17:15:47 +02:00
Nicolas Hake
a100b93e7f
DEBUG_BYTECODE_DUMP: Allow setting from build system
2016-05-11 17:15:47 +02:00
Nicolas Hake
16641d3841
C4AulScriptFunc::DumpByteCode: properly align BCC names
...
The old code just appended eight spaces when the type of the BCC was
shorter than eight chars.
2016-05-11 17:15:47 +02:00
Nicolas Hake
33f7fb935f
C4AulCompiler: Rename iStack to stack_height
2016-05-09 12:33:51 +02:00
Nicolas Hake
41000a8f9a
C4AulCompiler: Rename pLoopStack to active_loops
2016-05-09 12:21:33 +02:00
Nicolas Hake
d0dbe05876
C4AulCompiler: Rename fJump to at_jump_target
...
You have no idea how much I hate systems hungarian.
2016-05-09 12:21:33 +02:00
Nicolas Hake
7a135a060f
C4AulParse: Take GetTokenName out of public interface
2016-05-09 12:21:33 +02:00
Nicolas Hake
0a3b31e735
C4AulParse::AddVarAccess: Move to C4AulCompiler
2016-05-09 12:21:33 +02:00
Nicolas Hake
792e12adad
C4AulCompiler: Split into separate file
2016-05-09 12:21:33 +02:00
Nicolas Hake
c8d71d47c0
C4CodeGen: Rename to C4AulCompiler
...
I need to split up C4CodeGen into smaller parts, and having the bit that
actually generates the bytecode named C4CodeGenCodeGen would be silly.
2016-05-09 12:21:33 +02:00
Günther Brammer
9741af42fd
Replace all usages of the old local variables list with properties
2016-05-01 00:28:37 +02:00
Günther Brammer
7792acdff0
Script: Check for functions before keywords
...
This unifies the lookup for local variables and functions. Its slightly
awkward that global functions can overload if and Par now, but local
variables already could.
2016-05-01 00:28:37 +02:00
Günther Brammer
30f7457d89
Remove unused macros leftover from removed script features
2016-05-01 00:28:37 +02:00
Günther Brammer
b8f2d0ca87
Script: Repeat the parser error message when executing a broken function
2016-05-01 00:28:37 +02:00
Günther Brammer
17b18da26c
Make bytecode dump work again
...
Dumping the bytecode before adding EOFN while depending on that to signal
the end isn't such a hot idea.
2016-05-01 00:28:37 +02:00
Günther Brammer
4092911349
Move code generation into its own class
2016-04-28 03:25:47 +02:00
Günther Brammer
b00b8554ab
Merge branch script
2016-04-28 03:25:44 +02:00
Günther Brammer
d45ac946fe
Add C4AulParseError constructor and cease reusing it for warnings
...
The nontrivial code that formats the position is now a function of
C4AulParse used by both warnings and errors.
2016-04-28 02:59:12 +02:00
Nicolas Hake
a8f4bd3960
C4AulParseError: Avoid the second string parameter
...
While I'm not a big fan of hiding flow control in a function, Error()
handles formatting and saves me from calling FormatString().getData() a
lot.
2016-04-28 02:59:12 +02:00
Günther Brammer
525cdc11a3
Deduplicate calculation of the relative stack position of local variables
2016-04-28 02:59:11 +02:00
Günther Brammer
071feaa78f
Deduplicate loop control handling in the script parser
2016-04-28 02:59:11 +02:00
Günther Brammer
e22ca51f72
Don't leak references to Strings on script errors ( #583 )
2016-04-24 19:40:27 +02:00
Günther Brammer
5fbac346d3
Incompatible type warnings work for parameters with type declarations
2016-04-24 19:40:27 +02:00
Nicolas Hake
19a3d43558
Fix definition of explicitly sized enums
2016-04-24 15:20:28 +02:00
Nicolas Hake
caf44e2473
Remove specious space from Aul operator table
2016-04-24 14:01:23 +02:00
Nicolas Hake
770be2dafe
Aul: Allow AB_ERR to carry more detailed error information
2016-04-24 14:01:23 +02:00
Nicolas Hake
367f58b1cc
C4AulParseError: Enable creation from host and source pointer
...
Instead of having a C4AulParseError constructor read the location data
from the parse state, allow explicit construction from a known location.
2016-04-24 14:01:23 +02:00
Nicolas Hake
cfdb1142b8
Move C4AulParse declaration into separate header
2016-04-24 14:01:23 +02:00
Nicolas Hake
aa06b3b6f6
C4AulParse: Drop unused ATT_STAR
...
ATT_STAR has been rolled into ATT_OPERATOR and is no longer used
anywhere.
2016-04-07 20:52:31 +02:00
Nicolas Hake
f963a398aa
Define NORETURN annotation for MSVC
2016-04-07 20:52:28 +02:00
Nicolas Hake
eabca223f5
Update all copyright notices for 2016
2016-04-03 20:24:42 +02:00