New child language - (Function member address (structure))

Pages: 1... 1112131415... 20
hey will i be able to understand this child language? can i test it?
Thanks TheIdeasMan. Now I really understand why the float comparison sometimes fails.
I typed a test code, like this :

1
2
3
4
5
strcpy(string_test,"\
float fvalue = 23,\
printf(\"Current value : %f\nPlease enter a value (float) : \", fvalue),\
scanf(\"%f\",&fvalue), 45 ,\
printf(\"The value : %f\n\",fvalue)");


And tested it with 678.54.
Finally the program gives 678.539978, the value certainly is not equivalent to initial value 678.54 (678.539978 == 678.54 always returns false)
Even I set a double value instead of float but also it doesn't work...

devonrevenge wrote:
hey will i be able to understand this child language? can i test it?

Sure you can. Be patient.... :)

L B wrote:
Declare in header.hpp
Define in source.cpp


Oh, that's great! I googled it and finally I've solved the crazy problem. Oh that makes me very overjoyed!!!
Now my project looks like :

Static library

Source files
Expression.cpp
Function.cpp
Definition.cpp
Test.cpp
Main.cpp


Header files
Definition.h
Function_list.h
Macros.h


EssGeEich
Lol... :D

Oh, do you know? Over 90 % of functions total I used inline!!!! :D

EssGeEich wrote:
Useless, does it change anything from debug to release compilation? I guess not, except for an eventual 'debug' keyword on the title's name.

Before that I said the current project I am working on is a general version. So it's completely unrelated to compilation. What do you mean by "general"? :)

Woohoo!!!! Hooray!!! It's almost done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Did you take a look at the first example? Wow, I've just successfully called the function scanf. What's new? I picked "scanf " because it requires reference access. To call this kind of function properly, you have to cast all objects to pointers. Then, here's the syntax :

Symbol : & - Before any variable
r-value : illegal - will be ignored


int value, scanf("%d",&value), printf("Value : %d\n",value)

How to push values?, At beginning, I ever typed some crazy code like this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct function_parameter
{
union{
	int *lpint;
	short *lpshort;
	short *lpwstring;
	char *lpchar;
	char *lpstring;
	bool *lpbool;
	long long int *lplong;
	float *lpfloat;
	double *lpdouble;

	int nValue;
	float fValue;
	double dValue;
	char cValue;
	bool bValue;
	long long int lValue;
};
	enum variable_type type;
	unsigned int reference_level;
	unsigned int pointer_level;
};

OMG that...that's very horrible!!!!. That's about sixteen cases total!!!

Oh, looks like *void now is really useful. That's another help, hamsterman!!
...yes, any address can be assigned to a void*.


Basically each pointer value always holds 4 bytes stack (My OS certainly is 32-bit) :)

Simply with any pointer, I'll only need to :

1
2
__asm push lppointer;
nBytes+=4;


With the powerful definition *void, I can cast any regular value with :

1
2
3
4
5
6
7
8
9
10
11
void *lpvoid;

int a;
float b;
double c;
POINT d;

lpvoid = &a; //Ok
lpvoid = &b; //Ok
lpvoid = &c; //Ok
lpvoid = &d; //Ok 


And push them without causing any problem. :)


Done, level 1. Now I'm going to build up auto type variable now... Ha Ha Ha Ha...
Last edited on
Oh, I tried to input my first real code!!!
But I couldn't. :( Simply the cin command ignores the whitespace symbol. I called it "undefined behavior".

1
2
3
4
char string_test[300];
cout << "Please, enter an expression : ";cin >> string_temp;

cout << endl << string_temp;


Test code :
int a = 23, printf("Current value : %d, Input : ", a), scanf("%d", &a), printf("\nThe value : %d",a)


Output :
"int"


When cout << string_temp, I only see "int"...what's wrong? :(
Last edited on
"Undefined Behavior" that cin ignores whitespaces ?
Let me repeat you again: GAIN EXPERIENCE.

EDIT: Let me give you a hint: getline.
Last edited on
closed account (3qX21hU5)
Sigh I really don't know what to think about you JM in some posts you seem to have a good knowledge of C++ and can program some decent intermediate code, but then you post stuff like your last post where even beginners learn about getline() within the first month of so.

I agree with EssGeEich you need some more experience.

Also I second that this thread should just be ended or deleted by the admin because it is basically a one sided blog now and nothing else.
Wow, Ok, The problem has been fixed.
Thanks you very much EssGeEich!

Quick, I'm going to make a file loader, and like you said before, Zereo, this thread should be ended as soon as possible... :)

Last edited on
Let me repeat you again: GAIN EXPERIENCE.


Yes, GAIN EXPERIENCE. That's why I decided to develop this project. :)

Hah!! Very smart!!! Ultra fast!!!! Super fast!!! Extremely fast!!!!


Wow, instead of handle every function, I'll only need to use void*, and void*!!!!!

I discovered that a function also can be assigned to a *void. A great invention!!! It makes everything simpler and faster and smarter... Then, my next objective now simply is building up a switch - case, then sort it letter by letter, and, finally we have a super ultra-fast function call!!!!!!!

Compare this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

if(item == _pow)
{
__asm call pow
__asm add esp, nBytes
__asm mov ftemp, eax
__asm  fstp qword ptr [ftemp];
return stack_element(ftemp, mode);
}
if(item == _scanf)
{
__asm call scanf
__asm add esp, nBytes
__asm mov stemp, eax
return stack_element(stemp, mode);
}
else ... /???????????


With modern example :

1
2
3
4
5
6
7
8
9
10
11
12
13
void * lpfunction = 0;
switch (item){
     case _pow : lpfunction = pow; break;//Ok
     case _scanf : lpfunction = scanf;break; //Ok
     case _printf : lpfunction = printf;break; //Ok
     case _MessageBox : lpfunction = MessageBox;break; //Ok
}

if(lpfunction){
     __asm call lpfunction
     if(bBytesAddition)__asm add esp, nBytes
}


Wow, with lpvoid, now I don't need to bother anything else. Simply __asm call lpfunction, if you like, pop the stack, and enjoy the function call! Also the problem :

1
2
__asm call printf
__asm call dword ptr MessageBox


Now both two problems can be solved very easily :
1
2
3
4
5
void *lpfunction = printf;
__asm call lpfunction;

lpfunction = MessageBox
__asm call lpfunction;


Super great!!!! :DD
Last edited on
A bit about code style : The comma operator.

1
2
3
srand(time(NULL)),
int random = rand() % 13,
printf("Value : %d", random)


In short should I add terminator command symbol (;)? If I add it then in my point of view :
1
2
Easier to copy - paste C, C++ code.
Looks more clearly.


And the standard code below :
1
2
3
srand(time(NULL));
int random = rand() % 13;
printf("Value : %d", random)


I think maybe it looks better than the ugly one. :)
Last edited on
1
2
lpfunction = MessageBox
__asm call lpfunction;


And how are you pushing parameters? What about doing it?
closed account (3qX21hU5)
Is it just me or does it basically seem that JM is building well a interpreter that is almost exactly like C++ (I mean which the same type names and everything) but with a lot less features? Like why build the void* feature when C++ already has it, and auto and functions ect. ect. I can understand it as a project to build your skills but it wouldn't really be functional would it?

I'm not sure I'm following it right but that is what it seems like to me. So my question is why? Why not just use C++ and not use the features you don't want. Isn't the point of building your own interpreter to make things that C++ and other languages don't have and you want? Again I'm no expert on interpreters so correct me if I'm wrong.
Last edited on
EssGeEich wrote:

And how are you pushing parameters? What about doing it?


Firstly, calling a function you should avoid calling another function (E.g Accessing a vector parameter element requires a function call). Otherwise the program uses the current stack data instead and certainly it causes fatal errors :(

So that's why I decided to create a parameter structure.

 
bool CallFunction(Parameters &funcparam, unsigned int item, stack_element &returning_value);


funcparam stores a list of variable pointers. All temporary variables are temporarily used then deleted at the end of the algorithm.

1
2
int var = 10;
printf("Integer value : %d * %d = %d", var, 10, var * 10);


As you can see, the list of temporary variables :
1
2
3
"Integer value : %d * %d = %d" //string
10 //integer
var * 10 //temporary expression 


Only var is really a variable, so it's never affected.

Very simply :
- Create a for-loop, initialize the stack.
- I repeated this kind of for-loop two times, one is for storing all necessary information and one is for pushing all parameters.
- After that, try to detect function name, then call it.
- Finally check the returning value, and create a stack element. Some functions return nothing, so I just return false. :)
- Then free all data (funcparam).
Zereo
Thank you for your reply. I'll answer them later... :)

Wow, my idea is... (maybe a ridiculous idea)
Using *iterator to push a whole variable pointer!!! Is this possible?

1
2
3
4
5
vector <char> string;
//Initialize 100 char elements
iterator = string.begin();

strcpy(iterator, "Hello world!");
To call this kind of function properly, you have to cast all objects to pointers.
This disturbs me.
closed account (3qX21hU5)
This whole thread disturbs me. So lets just be blunt Jackson Marie, multiple people have told you nicely that this thread should end. But since that doesn't seem to be working I'll try this,

We don't want to see your page long blog posts show up every day on our recent topics, so stop posting! This is a forum to have a discussion and ask questions not post updates on your projects and have your own little blog. If you want to do that make your own, there are plenty of ways to easily do it. So once again please stop posting updates in this thread cause you aren't asking questions or even really taking advice, all it is a one way conversation.

I have a feeling most people feel the same way as me, but if they do like these little update of yours they will tell you and you can update them through PM's or your blog.

I also take responsibility for dragging this thread on by responding like this so I am sorry for that, I just JM very irritating and for some reason feel the need to reply. This will be my last post on this thread and hopefully JM will get the message and it will die out.
Jackson Marie wrote:
{quote=EssGeEich}
And how are you pushing parameters? What about doing it? {/quote}


Firstly, calling a function you should avoid calling another function (E.g Accessing a vector parameter element requires a function call). Otherwise the program uses the current stack data instead and certainly it causes fatal errors :(


Does it mean you will never be able to push a parameter when calling a function? DID you at least Understand my question?? If you call a function without proper parameter push/pop'ing your program will crash!
Last edited on
EssGeEich wrote:
If you call a function without proper parameter push/pop'ing your program will crash!


Simply that's why I decided to build up function type-cast, and many debugging features (Only DEBUG version).

General version : : A set of almost standard language syntax.

DEBUG : Slow but safe, and efficiency, with many debugging tools and other features.
RELEASE : Fast but generally it's very dangerous, the program certainly is not fully protected.


Zereo



I understand your concern, but anyways, you should not derail this thread.
:)

Zereo wrote:
just JM very irritating and for some reason feel the need to reply.

Do you really want this? But, lets me sorry for my fault. I should sometimes update my progress instead of "speaking" everyday! :)

Zereo wrote:
This will be my last post on this thread and hopefully JM will get the message and it will die out.


- No, it will never die. Also this is my final project (last project) in my life. As you can see I'm working extremely hard and trying to GAIN EXPERIENCE as much as possible. After that I'll bye C++ and never develop any other project anymore.

Zereo wrote:
...just be blunt Jackson Marie,

- That's lol... :)

Zereo wrote:
...but with a lot less features?


- Certainly a portable interpreter has a limited feature range.
Do you fully understand *void? Many posts are related to *void.

Zereo wrote:
build the *void feature

If I were you I would immediately use the available *void C++ feature instead of this (your thinking) :)

A linking example about C++ (600 MB) and small 200-300 kb interpreter :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void My_function([PARAMETERS])
{

     //do something;
     //Load music
     //Load video
     //Play them!
}

int main()
{
      Stack stack;
      Classdata world;
     //initialize the expression....

     function_manager.AddFunctionItem("My_function", My_function);

     Expression(string, stack, false, &world);
}


Do you really understand this? That's totally a library (I chose static). You can load an unknown source file then test it without compiling and linking or fixing crazy errors. You also can call local functions which are compiled, linked and defined elsewhere in your program.

File example wrote:

printf("File start !\n");

InitGraphic();
My_function("birdsong.mp3", "background.avi");




All modern compilers have to compile, link, and build an executable file with the code that users specified. The code should be "no errors". The executable files are presented in a way that everyone called "assembly". That's unique. Only portable interpreter (portable)? compiles and runs a source file at a time, you can freely switch to an another file at anytime you want, each source file is a program that you can instantly enjoy it...
Last edited on
Obviously you didn't get what I mean:

1
2
3
4
5
6
7
8
9
10
11
12
13
14

// C++
int Result = MessageBox( NULL, "Test", "Title", MB_OK );

// Becomes in asm something like...
push 0 // MB_OK
push (Address of Title)
push (Address of Test)
push 0
call MessageBoxA // MessageBoxW if unicode
// With certain calling conventions, clear the stack by pop'ing.
// Being MessageBoxA/W stdcall you don't need it now.
mov eax, Result


In ANY other way which does NOT push enough parameters, the program WILL crash unless you handle the error, but still you will have UNDEFINED behaviour.

Jackson Marie wrote:
All modern compilers have to compile, link, and build an executable file with the code that users specified. The code should be "no errors". The executable files are presented in a way that everyone called "assembly". That's unique. Only portable interpreter (portable)? compiles and runs the source file at a time, you can switch to an another file anytime you want, each source file is a program that you can instantly enjoy it...


You're not making a compiler. You're making an interpreter - Don't compare it to a compiler. It will never have the same speed as a compiled-linked executable. Also expect runtime errors - Which are harder than compiletime errors.
Last edited on
What is "*void"?

I understand what "void*" is, it is a void pointer, or a pointer with no specified type to point to. But "*void" does not make sense to me.
*void is nothing. You could have *(void*) but that would be dereferencing a void pointer, which is illegal (or undefined, can't remember which).
Well you cannot dereference a void pointer - It won't compile. So I guess it's illegal?
Pages: 1... 1112131415... 20