Commit graph

319 commits

Author SHA1 Message Date
4255fc30d5 Resolver - Removed unused import 2023-01-12 08:41:35 +01:00
599652e98e Resolver - Refactored to work with the new class structure 2023-01-12 08:41:04 +01:00
0dbc631c96 Parser - Disallow static initializers 2023-01-12 08:40:21 +01:00
b77d69c989 Parser - Static methods 2023-01-12 08:15:36 +01:00
24c39a2c9d Scanner - Static keyword 2023-01-12 08:15:26 +01:00
0a31442d56 Dumper - Support static methods 2023-01-12 08:09:23 +01:00
52c4b6315e AST - Refactored class member representation 2023-01-12 08:06:58 +01:00
6387615f68 Tokens - Added Static 2023-01-12 08:02:01 +01:00
0ebe2e9f22 Interpreter - Class properties 2023-01-12 07:39:12 +01:00
09b4b4e688 Interpreter - Refactored getter/setter support as a trait on an instance ref 2023-01-11 19:44:52 +01:00
8b19f546c8 Parser - Removed handling of 'return' special cases
* This has been implemented in the resolver so it's pretty pointless
    to do it twice
2023-01-11 15:33:41 +01:00
ee53c2fba4 Resolver - Improved handling of 'return' 2023-01-11 15:33:21 +01:00
57a5a62300 Resolver - Check return statements in the resolver 2023-01-11 15:30:24 +01:00
406400bf71 Resolver - Don't reset scope types while parsing function blocks 2023-01-11 15:29:48 +01:00
aa48973e23 Resolver - Support and detection of the initializer scope type 2023-01-11 15:19:21 +01:00
0a581f042d Resolver - Keep track of the container scope's type 2023-01-11 15:15:40 +01:00
47c4136c25 Interpreter - Refactored instance to avoid runtime borrom problems 2023-01-11 08:21:48 +01:00
c4f0f0f721 Interpreter - Fixed special case for init 2023-01-11 08:03:42 +01:00
3af544a78e Interpreter - Initialize support in instances
* Doesn't work at this point
2023-01-11 07:50:02 +01:00
783a2e3dd0 Interpreter - Special case for initializer methods 2023-01-11 07:46:13 +01:00
98eef78583 Clippity clip clippy 2023-01-11 07:21:50 +01:00
ecc8f2ec8b Removed various bits of unused code 2023-01-11 07:20:29 +01:00
16151bd326 Actually made "this" work in the interpreter 2023-01-10 09:03:57 +01:00
3e4aea0d78 Interpreter - Working bound methods 2023-01-09 11:19:42 +01:00
542bc56aad Interpreter - Initial implementation of bound methods 2023-01-09 10:50:24 +01:00
a2986a1342 Resolver - Class definitions create a scope that contains "this" 2023-01-09 10:48:50 +01:00
e46b399399 Interpreter - Handle references to "this" 2023-01-09 08:03:41 +01:00
f9359cfe03 Interpreter - Refactored lookup_var() to use VariableExpr 2023-01-09 08:02:59 +01:00
ea4717c8bd Resolver - Handle the "this" keyword 2023-01-09 07:59:55 +01:00
1f4aecd099 Resolver - Refactored resolve_use() to use VariableExpr 2023-01-09 07:59:04 +01:00
7e7c8ffc37 Parser - Handle the "this" keyword 2023-01-09 07:56:58 +01:00
c9f74cdc55 AST - "this" keyword 2023-01-09 07:53:56 +01:00
dbd0f6d20f Interpreter - Handle AST refactorings 2023-01-09 07:51:40 +01:00
b12c7a05cf Resolver - Handle AST refactorings 2023-01-09 07:49:19 +01:00
0c588942bf Parser - Handle AST refactorings 2023-01-09 07:46:42 +01:00
bb2765d057 AST - Refactored variable reference expressions 2023-01-09 07:43:45 +01:00
75387c5ac4 AST - Refactored binary expressions 2023-01-09 07:40:28 +01:00
58c1bbcf68 Interpreter - Access methods through get expressions 2023-01-09 07:32:50 +01:00
e371217df0 Interpreter - Initialize methods when creating classes 2023-01-09 07:32:29 +01:00
392aaa630d Resolver - Apply resolution to methods 2023-01-09 07:22:15 +01:00
16bf06c7a1 Resolver - Added some spacing 2023-01-09 07:11:18 +01:00
5cfe6d3e5c Interpreter - Set instance properties 2023-01-09 07:10:10 +01:00
7634354122 Resolver - Set expressions 2023-01-09 07:02:52 +01:00
a52e386e8d Parser - Set expressions 2023-01-09 07:00:52 +01:00
a5172e103b Dumper - Set expressions 2023-01-09 06:56:47 +01:00
2bdf675090 Dumper - Get expressions 2023-01-09 06:55:41 +01:00
082acaaa1e AST - Set expressions 2023-01-09 06:54:03 +01:00
2b4ecf6d2c Made Clippy slightly less unhappy 2023-01-08 15:27:19 +01:00
1c5efe7e62 AST - Replaced dumper
* Rewrote as a kind of "pretty" printer
  * It isn't actually pretty but it does restore Lox code from the AST.
2023-01-08 15:25:27 +01:00
728c7a3857 Interpreter - Renamed class submodule to classes 2023-01-08 12:02:45 +01:00
5062e6c348 Interpreter - Instance fields 2023-01-08 12:01:05 +01:00
f8bcc2d703 Interpreter - Evaluate get expressions 2023-01-08 12:00:50 +01:00
20aa06ac25 Parser - Fixed parameter parsing bug 2023-01-08 12:00:01 +01:00
e963868aa7 Interpreter - Value helper methods to run code against instances 2023-01-08 11:57:56 +01:00
d07dbb2e89 Resolver - Get expressions 2023-01-08 11:32:09 +01:00
334dc99752 Parser - Some refactoring of code that handles identifiers 2023-01-08 11:31:02 +01:00
e006a12c80 Parser - Support for get expressions 2023-01-08 11:22:49 +01:00
616565bb0d Token - Helper methods to better handle identifiers 2023-01-08 11:22:14 +01:00
0cebffbf9b AST - Getter expression 2023-01-08 11:04:32 +01:00
7306fa0cfa Parsed - Fixed class parser 2023-01-08 10:58:02 +01:00
af68acde70 Clippy, clippy, clippy! 2023-01-08 10:44:46 +01:00
d8dba3ac5f Rewrote value storage and implemented class instantiation
* Probably not the last time.
  * Object-like things (functions, classes, etc...) are stored as
    ref-counted cells.
  * Separate data structure for native functions.
  * with_callable() method on value to run specific code on objects
    that are callable
  * Instance type added.
  * Instance construction implemented
2023-01-08 10:40:36 +01:00
85e9c7db38 Interpreter - Callables now receive the callee value as an argument 2023-01-08 07:58:56 +01:00
692531ca65 Interpreter - Class declarations 2023-01-07 14:21:10 +01:00
f834d84365 Interpreter - Class values 2023-01-07 14:15:04 +01:00
6fa335b2f6 Interpreter - Basic, mostly empty class data structure 2023-01-07 14:14:45 +01:00
afb465d6df Interpreter - Use Value.to_string() for print statements 2023-01-07 14:14:24 +01:00
621ca9d9f1 Interpreter - Class submodule 2023-01-07 14:08:31 +01:00
9bfb549a22 Resolver - Class declarations 2023-01-07 14:07:59 +01:00
5702abe44d Parser - Parse classes
* New FunctionKind value for methods (with only 254 arguments)
  * Class parsing
  * Some minor refactoring of function parsing
2023-01-07 14:05:17 +01:00
36026681f7 AST - Added class declaration statements 2023-01-07 13:53:43 +01:00
1af25457d5 AST - Refactored function declarations as a separate struct 2023-01-07 12:18:18 +01:00
6252bed605 Happy clippy is happy (and Clippy) 2023-01-07 11:59:32 +01:00
8741692fad Resolver - Store declaration tokens as references 2023-01-07 11:55:41 +01:00
34991d4b4b Resolver - Report an error if a symbol isn't used 2023-01-07 11:41:04 +01:00
670b50e8cd Scanner - Allow identifiers with a leading '_' 2023-01-07 11:39:19 +01:00
4bce85e14b Resolver - Errors on undefined symbols 2023-01-07 11:10:24 +01:00
06917ca2d6 Resolver - Split resolve_local() into specific methods 2023-01-07 11:06:22 +01:00
24d9d6d880 Resolver - Handle the global namespace as well 2023-01-07 10:58:02 +01:00
c971df6f60 Resolver - Refactored declare() 2023-01-07 10:53:05 +01:00
8d65c288a3 Resolver - Refactored entering/exiting scopes 2023-01-07 10:51:34 +01:00
6dceae73a0 Resolver - Additional checks
* Ensure all locals are defined before they are used.
  * Prevent functions declared using fun from being assigned to.
  * Mark locals as used when they are accessed.
2023-01-07 10:17:08 +01:00
a89be8632c Missed a rename in previous commit 2023-01-07 09:17:02 +01:00
95ddd34f9c Interpreter - Renamed resolved variables field 2023-01-07 09:01:24 +01:00
363cdab86f Interpreter - Fixed closures
* Environment for function execution is now based on their
    declaration.
  * I had missed that part while skimming over the book.
2023-01-07 08:59:13 +01:00
ec70ded29e Fixed variable lookups and assignments 2023-01-07 08:48:21 +01:00
3117dfeac5 Interpreter - Lookups and assignment based on resolver results
* Does not work. Using pointers was a bad idea.
2023-01-07 08:24:27 +01:00
bd156e619f Trying to implement variable lookup and failing hard
* I'll probably have to rewrite environments as a Vec<HashMap> to make
    things simpler
2023-01-06 08:05:33 +01:00
c97ad0ad7e Interpreter - Made the interpreter state partially public
* This allows Callable to be public, which is required for Value
  * State internals are still hidden behind pub(super)
2023-01-06 07:47:45 +01:00
10223cbb4e Interpreter - WIP refactor to prepare for using resolved variables 2023-01-05 07:54:18 +01:00
d528ce8dc3 Interpreter - Limited scope of some declarations 2023-01-05 07:21:43 +01:00
754659ed12 Resolver - Removed invalid fix mistakenly committed in 79a0667 2023-01-05 07:13:20 +01:00
c90731b62d Resolver - Comments 2023-01-05 07:12:21 +01:00
64bc8312dd Resolver - resolve_function() shouldn't be a method from ResolverState 2023-01-05 07:09:35 +01:00
b5573cee3b Resolver - Fixed off-by-one error in resolve_local() 2023-01-05 07:06:27 +01:00
79a0667f34 Resolver - Errors on duplicate declarations 2023-01-05 06:58:29 +01:00
c1a61b992d Scanner - Style clean-up 2023-01-05 06:43:54 +01:00
c5f099340b Errors refactoring - Code compiles. 2023-01-04 07:58:44 +01:00
743379c516 Errors refactoring for the iterpreter 2023-01-04 07:49:28 +01:00
7961a92ad1 Further attempts at refactoring the error handling code
* Everything's still broken though
2023-01-04 07:35:40 +01:00