Commit graph

573 commits

Author SHA1 Message Date
George Marques
b7bd85e70c
GDScript: Look up local scope first for detecting type 2018-07-25 20:50:11 -03:00
Hein-Pieter van Braam
0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
George Marques
3e87ad5187
Rewrite code completion
- Use data type struct from the parser.
- Avail from type hints when type can't be guessed.
- Consider inner classes and other scripts when looking for candidates.
2018-07-20 21:55:18 -03:00
George Marques
3445dca01d
Add ability to infer variable type from assigned value
Syntax: var x : = 42
Infers the type of "x" to be an integer.
2018-07-20 21:55:18 -03:00
George Marques
03746da73f
Add editor highlight for type-safe lines
The line number is hightlighted to indicate that the line contains only
type-safe code.
2018-07-20 21:55:18 -03:00
George Marques
a2305cd8b2
Fix line number detection in some parser nodes 2018-07-20 21:55:17 -03:00
George Marques
75f395c2a0
Use type hints to improve completion
- Allow type hints to be completed.
- Use type information to infer completion candidates.
- Show typed function signature in tooltip.
- Add type hints when completing declaration from virtual functions
(optional).
2018-07-20 21:55:17 -03:00
George Marques
95351ac867
Add syntax highlighting to type hints 2018-07-20 21:55:17 -03:00
George Marques
e3d72d14ff
Use type information to enable GDScript introspection
This makes the Script API provide accurate information when requesting
property or method info.
2018-07-20 21:55:17 -03:00
George Marques
4b18c4e448
Add typed instructions to GDScript
- Typed assignment (built-in, native, and script).
- Cast (built-in conversion; native and script checks).
- Check type of functions arguments on call.
- Check type of members on set.
2018-07-20 21:55:17 -03:00
George Marques
743053734f
Add static type checks in the parser
- Resolve types for all identifiers.
- Error when identifier is not found.
- Match return type and error when not returning a value when it should.
- Check unreachable code (code after sure return).
- Match argument count and types for function calls.
- Determine if return type of function call matches the assignment.
- Do static type check with match statement when possible.
- Use type hints to determine export type.
- Check compatibility between type hint and explicit export type.
2018-07-20 21:55:16 -03:00
George Marques
f7793fc5c9
Store type hint of declared identifiers 2018-07-20 21:55:16 -03:00
George Marques
b7a00aead0
Move inheritance resolution to the parser 2018-07-20 21:55:16 -03:00
George Marques
8aab9a06d4
Add typing syntax 2018-07-20 21:55:16 -03:00
Rémi Verschelde
7c9f7452f4 Style: Format code with clang-format 6.0.1 2018-07-18 16:27:03 +02:00
Juan Linietsky
a3f1ee5c57 Global class names (and GDScript support for it) 2018-07-15 19:29:00 -03:00
Max Hilbrunner
3f272c6ae6
Merge pull request #19637 from dragmz/19548
Fix onready vars / vars accessing class members if _ready / _init not present
2018-07-05 04:15:47 +02:00
Max Hilbrunner
d988d188ad
Merge pull request #18966 from chanon/new-debug-print
Add new debug print method that shows line number where the print came from
2018-07-04 23:50:45 +02:00
Max Hilbrunner
aad475937b
Merge pull request #19828 from jjay/fix_yield_leak
Fix memory leak in GDScript during infinnity loops with yields
2018-07-03 18:51:13 +02:00
Max Hilbrunner
5885e1c6dd
Merge pull request #18976 from chanon/new-get-stack
Add new get_stack function to get GDScript stack trace as array
2018-07-03 17:50:05 +02:00
Max Hilbrunner
0705eb904a
Merge pull request #19251 from YeldhamDev/script_templates_changes
Small changes to the comments in the script templates
2018-07-03 16:48:03 +02:00
Yasha Borevich
30317296af Fix memory leak in GDScript during infinnity loops with yields 2018-06-28 23:55:30 +03:00
Marcin Zawiejski
317dcb084b Fix onready vars / vars accessing class members if _ready / _init not present 2018-06-18 23:31:48 +02:00
Bojidar Marinov
8ecef3496c
Add proper type information to array property
Part of #19158
2018-06-18 22:24:31 +03:00
Paulb23
08c036b706 Removed duplicate default colours and removed GDScriptHighligher colours from main editor. 2018-06-13 18:25:02 +01:00
Rémi Verschelde
f0fa590210
Merge pull request #19526 from robojumper/fix_tutorials
Add support for tutorial links to makerst.py
2018-06-13 14:29:45 +02:00
robojumper
98b59cf2a3 Add support for tutorial links to makerst.py
Also change the <tutorials> structure to make use of individual <link> tags
2018-06-12 17:40:24 +02:00
Jairo Honorio
afcac41d31 Inner classes' functions now appear in the editor's functions panel
Fixes #19386
2018-06-12 10:43:37 -03:00
Michael Alexsander Silva Dias
fd17b960e9 Small changes to the comments in the script templates. 2018-06-11 02:04:51 -03:00
Rémi Verschelde
3334209a73 SCons: Pass env to modules can_build method
This allows to disable modules based on the environment,
in particular `env[tools]` which tells us if we are
building the editor or not.
2018-05-30 19:11:36 +02:00
Fabio Alessandrelli
8e35d937a9 New sync keywords in GDScript, NativeScript, Mono 2018-05-29 20:26:41 +02:00
Fabio Alessandrelli
1400f6fdc4 Refactor RPCMode enum and checks 2018-05-29 20:26:41 +02:00
Max Hilbrunner
4c69a495c9
Revert "RPCMode refactor, more sync modes" 2018-05-29 11:47:52 +02:00
Max Hilbrunner
d0b62ce155
Merge pull request #19021 from Faless/rpc_sync_fix
RPCMode refactor, more sync modes
2018-05-29 09:44:03 +02:00
George Marques
38284bc6da
Enable singletons to be recognized as constant expressions
Fix #14681
2018-05-28 13:40:16 -03:00
chanon
3ea6d9f37d add new print_debug method which shows source and line number 2018-05-28 18:37:07 +07:00
Fabio Alessandrelli
a5e8a3be5e New sync keywords in GDScript, NativeScript, Mono 2018-05-26 10:49:33 +02:00
Fabio Alessandrelli
9de4ffde61 Refactor RPCMode enum and checks 2018-05-26 10:43:43 +02:00
Max Hilbrunner
aee8d26252
Merge pull request #19131 from YeldhamDev/connection_comment_capitalize
Capitalized comments of methods created by the Connect Signal dialog
2018-05-24 01:21:17 +02:00
Michael Alexsander Silva Dias
4e257293d9 Capitalized comments of methods created by the Connect Signal dialog. 2018-05-23 18:11:00 -03:00
George Marques
3cec24baa8
Fix positive operator in GDScript compiler 2018-05-23 17:43:56 -03:00
chanon
a56d6ff35f add new get_stack function to get GDScript stack trace as array 2018-05-17 21:06:30 +07:00
Rémi Verschelde
b0649d2718
Merge pull request #18405 from flashyincceo/gdscript-constants-help
Fix Ctrl+click on @GDScript constants
2018-05-17 09:36:55 +02:00
Juan Linietsky
47d4a011d8
Merge pull request #18545 from vnen/editor-autoload
Enable autoload in editor
2018-05-14 17:59:34 -03:00
Rémi Verschelde
919d802e66
Merge pull request #18183 from Paulb23/gdscript_highlighter_inital_changes
GDScript function definition and get_node shortcut syntax highlighting
2018-05-10 01:25:51 +02:00
Juan Linietsky
299d8a80ba
Merge pull request #16106 from poke1024/gdscript-lerp
GDScript: generalize lerp
2018-05-07 20:36:31 -03:00
Juan Linietsky
ff1e7cfbf4 Add is_instance_valid() method to GDScript, ending more than a decade of pain. 2018-05-07 17:30:03 -03:00
Max Hilbrunner
ffb6f8f1ca
Merge pull request #18406 from YeldhamDev/script_templates_period
Changed periods in the script templates
2018-05-04 11:20:16 +02:00
Rémi Verschelde
460e551ddf
Merge pull request #16418 from bojidar-bg/15961-gdscript-array-export
Allow exporting arrays of resources in GDScript
2018-05-03 21:19:15 +02:00
Michael Alexsander Silva Dias
093b069bf6 Changed periods in the script templates. 2018-05-02 11:42:09 -03:00