Script formals to function formals

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Jan 10, 2005 at 13:21

I am currently in the process of implementing a scripting engine into the core of my game engine. The language will not be incredibly advanced to start with; I just want to get it up and running, with a functional front- and back-end, and then I will add features.

One of the things I have been pondering about lately is the ability to call native engine functions from the script, functions that would be too slow for script execution. One of my current ideas is to map native functions in the engine to literal symbols, which would be easy to recognize and transform from the script manager/handler/whatever. On loading scripts, these symbols would then be substituted with function pointers, so that a lookup is not required on every native call.

My concern then comes to calling the native functions. They are not restricted to any number of specific parameters, so typedef’ing a common function type would not be practical. My idea was to write some assembly code to handle the loading of the different types of parameters, and then push those variables on to the stack. What I do not know, is how to do this efficiently. I am not that confident in the realm of assembly, but it would make it easier than doing it in C/C++ (if that is even possible). I have not decided on any final type of script stack, so anything is still possible. My first idea is to have two separate stacks: one for the script variables, and one for the values of the variable. The first stack of a common variable class, will hold different kinds of information on the values it points to in the second stack, which will just be an array of bytes, like offset, count and size. All the values of the script stack lay in a linear array, and I was wondering how different this is from the registers EBP/ESP. Would it be possible to just push the position of the first value on the value stack? This would remove any kind of formal-type recognition, and the need to write special code for different variable types.

Everyone is encouraged to toss any idea or suggestions you might have into the pool, everything will be appreciated. I have never done anything like this before, so all kinds of feedback is will surely help.

  • Kenneth

6 Replies

Please log in or register to post a reply.

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Jan 10, 2005 at 14:33

i’ve just taken the easy way out and made a switch sentence :D
now my script lang is also only 10 instructions :cool:

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Jan 10, 2005 at 16:26

http://www.drizzle.com/\~scottb/gdc/fubi-paper.htm

if i understand you correctly this is exactly what you want

065f0635a4c94d685583c20132a4559d
0
Ed_Mack 101 Jan 10, 2005 at 17:13

Just the article I was about to refer too :) I found it in Game Programming Gems

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Jan 10, 2005 at 17:20

He he :D
I have already read that document, and I am not comfortable with scripts being able to call all my exported function (my engine.dll has \~1400, core.dll \~900), especially not functions like ‘appCoreExit()’, ‘appFatalExit()’, ‘GiveMyCharacterInfinteLifeAndAllWeapons()’ and so on, you get my point.

But thanks for the reply, keep ‘em coming!

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Jan 10, 2005 at 17:36

@JSoftware

i’ve just taken the easy way out and made a switch sentence :D
now my script lang is also only 10 instructions :cool: [snapback]15031[/snapback]

10 instructions!?! My last VM had 140 instructions, and that was not even enough :blink:
Must be low in functionality…

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Jan 11, 2005 at 04:50

Indeed it is
it’s a stew of pic assembly and int 16.. with just the basic ops
but it works and it’s fast as hell