Beginning Work on NXC Memory Manager

If you haven’t heard already, I’ve begun work on a “Memory Manager”.

What it does

Using my library (libraries, actually), you’ll be able to:
[Please insert "pseudo-" in front of all the list items.]

  • Create variables (bools, [unsigned] chars, [unsigned] ints, [unsigned] longs, floats, doubles, strings, and arrays of those types, too)
  • Set their values (working on it; support for different ops is being added)
  • Pointers! (And pointers to pointers, or pointers to pointers to pointers, or pointers to pointers to pointers to pointers, or…)
  • Use “hash tables” (working on it)
  • Parsers of [obfuscated] expressions (… guess; yeah, you’re right: I need to finish the hash stuff first)
  • “Dynamic” memory management
  • Dynamic typing (if you’re insane enough to want this), and duck typing (I just wrote this down for kicks, actually; quack quack)
  • Function overloading
  • Possibly operator overloading
  • And definitely use super advanced kung-fu fighting robot functions

Example code

By “pseudo”, I mean you won’t be able to do this:

int lol = 42;
int *pi = lol;
NumOut(0, 0, *pi, 0);

But we will have something similar to this:

MM_ID lol = MM_new(MM_ID_TYPE_INT);
// prototype: MM_ID MM_new(MM_ID_TYPE type = MM_ID_TYPE_BYTE, unsigned long len = 1);

MM_mov_INT(lol, 42);
// or use MM_set_INT(lol, 42);

MM_ID pi = lol;

NumOut(0, 0, MM_get_INT(pi), 0);

It’d look a lot nicer if NXC itself supported function overloading. >_> :D Assuming it did, here’s the new version:

MM_ID lol = MM_new(MM_ID_TYPE_INT);
MM_mov(lol, 42);
MM_ID pi = lol;
NumOut(0, 0, MM_get(pi), 0);

No more _INTs!

Or, if you take my “parser” into account, something similar to this:

P_parse("int lol = 42;");
string pi = "lol";
NumOut(0, 0, P_get_INT(pi), 0);

How to contribute

If you’re willing to help, you can become a tester. I don’t have a NXT with me all the time, so I post things for people to test at the Memory Manager thread on the Mindboards Forums.

Also, I’ve set up a Mercurial repository, if you want to check out my progress.

About these ads

~ by muntoo on March 18, 2011.

3 Responses to “Beginning Work on NXC Memory Manager”

  1. Wow, that’s awesome! I’ll definitely be willing to beta test and stuff.

    • Thanks, you can start here. :)

      —–

      I think I’ve figured out a way to get pseudo-”recursion”. I’ve made a post here. If John doesn’t implement it, I might make a “pre-parser” that you “parse” your recursive functions with to transform them into “iterative” functions.

      (If you can give me more technical words to replace the ones with “quotes” around them (to make me sound all geeky), please feel free to correct me! …Within reason. :))

  2. For anyone who’s interested, I’ve set up a Mercurial repository, if you want to check out my progress.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: