- you didn't see the code about these question, because i'm trying get some information... i must finish somethings for it ;) |
Well I can't comment on code I can't see, still after 1 week I am just trying to see what it is you want to do regarding the original question.
hey i'm using the compilation: |
Yes you are compiling (converting the VB into C++), but I had the impression that there was a mixture of C++ and VB. Maybe this impression is wrong?
If you are going to have a file with sections of pure C++ followed by sections of pure VB, then you could cheat by tagging those sections with some kind of comment:
1 2 3 4 5 6 7 8 9 10 11 12
|
//C++
// C++ code here
//...
//End C++
//VB
//VB code here
// ...
//End VB
| |
Then write the C++ code to another file and compile it separately.
If you don't do that, then you will be writing your own compiler to compile C++ code ....
This again takes me to the conclusion of using .NET , and you won't have to write any Win32 code.
- theres 1 thing that i don't like, realy, make the class header on 1 file and then define it on other file, i think, it's 2 works and make the things more separed... ok it's a person opinion; |
Some of the reasons we have separate *.cpp and *.hpp files are:
* it allows reuse of the header files ;
* it makes life easier for the coder by keeping things separate ;
* we are not writing spaghetti code.
So it is more than a personal opinion.
With the code that should be in the main.cpp: only the Main function that you have, and line 1146 which should be inside Main function, not a global variable.
With the destructor of the compiler class:
If you have code in a destructor, then you are not doing RAII. However the code looks redundant, clearing the data from those vectors is pointless because they will be destroyed when they go out of scope.
maybe you can tell me more about the comments. |
To make functions smaller, have them call other functions. The candidates for what can be in a function can include:
* the body (between the braces) of any of the loops (
for
,
while
,
do
)
* the body of
if,
else if
,
else
statements
*
switch
statements
* the
case
s in the switch. Each
case
calls a function
Not all of these functions need be member functions of the compiler class. It might be possible to have some of them being free functions, otherwise they can be
private:
or
protected:
member functions, obviously some will necessarily be public.
You don't seem to have any kind of AST, so I can't help thinking that will be very limiting. For example can you process this:
(a+b)/2.0;
?
The AST in the llvm compiler can process nested expressions, the more it is nested, the more it adds to the tree, this includes function calls too.
So with your project overall, you have, so far:
1. Converting VB code to C++ via compilation, with some Win32 code, in a limited fashion;
2. Wanting to use windows Forms with controls on them, with Win32 code.
If your project was just 1. without the Win32 code, then that might be feasible if written in pure C++. For example one could compile VB on Linux. Even then there is this:
http://www.cplusplus.com/forum/lounge/246990/
But given requirements 1 and 2, this strongly points to using .NET (in my opinion), otherwise you would write massive amounts of code to reinvent the wheel. As far as I know, .NET was invented so one didn't have to write Win32 code, a lot of things can be done visually, without having to write much code at all.
I am sorry if this sounds terribly negative :+| But this is not the first time I have come across a project where a lot of time has been spent and lots of code written, but the coder has been unaware of what is already available. Then someone comes along, pours freezing water over the whole thing, and advises to abandon the existing code altogether. In these cases the coder is often unwilling to abandon everything, they can't seem to get over the investment they have put in, they see it all as a waste, but prefer to continue, eventually realizing they didn't achieve much. This sometimes happens in professional software development projects too, something will happen which in hindsight is a project killer, but they persevere and finish up wasting 10 times more money.
On the other hand, some people purposely do things like writing there own vector class for example, as a learning exercise. So you could continue with your project as a learning exercise if you want. Maybe use the llvm compiler directly, or at least learn about the AST. Using llvm is probably the easiest thing. Implementing your own AST would be a greater amount of work.
Or you could use llvm to compile a language that is only available on Windows, with a view to making an executable on another OS. It might be tough to find a language like that. I use the Eclipse IDE, it has plugins for lots of things, including all kinds of scripting, procedural and functional languages. This would also involve having to learn a bit about another OS, that is a good thing too
Or if you have a huge imagination, you could invent your own language :+D
As a final note, I keep mentioning llvm because it seems reasonable to me, but there may be other tools too.
Good Luck !!