Tangent: Cleaning up my mess.

Published June 30, 2008
Advertisement
Everyone is going out of town this weekend except for me, so I'll have the long weekend to drink mountain dew, eat swedish fish and work on Tangent. w00t.

As a lead up to that, I had tonight free so it went to do some cleanup work on the method declaration bits. There were... probably 4 major problems with method invocation and declaration as they were naively implemented before.

1. I had to change my approach, which caused me to lose the names of parameters. This kinda meant that you couldn't refer to them within the method...

2. I didn't nicely instantiate the per-instance set of variables for a method. This meant that recursion (and multithreading, if it existed) didn't always work as it was supposed to, since the parameters/return values could be overwritten. Oops.

3. The code to replace type expressions with actual types during compilation was dumb. Super dumb even, so anything more complex than 'void' would run into issues.

4. Unfortunately, the code that defines a Type and the code that defines a Type while it's being compiled are not the same. So any compiled type (say... int, or string) wasn't quite available to the compiling code. And since it's not implausible that a Type is going to be extended during compilation (operator overloading for example) I can't just leave them as plain types.


Mostly though, it was a mess because I've been working on this beastie for a few months now, and at times threw stuff together to make a milestone work. Good for me, since I've a habit of not 'getting stuff done'. Bad for me because it makes messy code. Not super messy, and fixing it isn't too painful these days, but it still requires some time for maintenance.

Problem one is unfortunately not fixed. For now the parameters are available using simply 'Parameters' or 'Parameters[index]'. Problem two was fixed by doing proper instantiation of an execution context per method. Problem three was fixed by adding code for expression understanding and anonymous type creation for each step of the expression. Problem four's solution involved a little special casing and a translation method to convert Types into their unbuilt representations for use and/or extension.

Class declarations sort of work in code now too. You can't instantiate them, and I think there's some funkiness around the initialization bits for them and maybe some of the instance methods. I need to come up with a good test case to work towards.

And for interest, the test Tangent code that I focused on getting working tonight:

public static void main(){    foo(2);} public static void foo(int x){     print Parameters;     foo(Parameters+Parameters); }


For the weekend: debug class declarations, make 'new' work, control structures, further operators for built-in types.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement