Convert the compilable statements into an another programming language

First, you write some statements with the editor page.
Second, you answer values for parameters.
Third, you convert these statements into the following programming languages :
  • VBScript
  • PowerShell
  • C++ .NET (Windows)
  • C++ (Unix)
  • C++ (MacOS)
  • C# .NET
  • Java
  • Perl
  • Python
  • HTML/JavaScript
  • or XSLT

Some of these programming languages are strongly or lower typed. For example, VBScript conversion makes functions with parameters and local variables without a given data type. And these parameters are always mutable. Hence, the data flow is more easily than others languages.

Otherwise, PowerShell uses passing parameters by value or by reference : the syntax in using a variable passed by reference is not the same than a variable passed by value. Here, expressions assignments infers the data type.

But, C++, Java and C# are stronly typed programming language. Also, you have to add a data type for each local variables and parameters. The data type is no longer infered by the expression in assignment statements. For each value, there is an unique variable name. Because of that, a variable could have multiple instance values stored in multiple C++ variables names.

Now, if a variable is assigned in C++, the assigned variable has a name and a specific data type. And, after the assignment the current value is stored in a new variable name. Hence, I need to keep actually the use of that variable with the good data type.

But, shortly if a variable is assigned in C++, there is no inference type : if the expression is an incorrect data type result, you have to convert the expression with the data type defined with the variable name. And, with these expressed terms, using a variable in a data type results in a data type conversion.

VBScript

Dim i
i = 0
i = CStr(i)
i = CLng(i) + 1

PowerShell

$i = 1
$i = $i.ToString();
$i = [Convert]::ToInt32($i) + 1

C++

In this example below, the toString function is a new prototype to implements a conversion from a number to the standard library template data type std::wstring.

int n_i = 0;
std::wstring ws_i = toString(n_i);
n_i = toInt(ws_i) + 1


Again, there is a tricky conversion : all loops and conditional operations.

Loops

In a C++ loop, you probably go to the end of the loop and you probably return to the first statement of the block statement loop and execute the block again and again until a limit condition.
What happens if data type are different between the loop's starting and the loop's ending ?

If the initial variable value is an integer and that final variable value is a string, replays will make the variable an undetermined state. That's not what I want. The initial and final values have to be the same.

Conditional branch out

In C++, variables can be updated at any time in the scope of the variable. Updating a variable in the first true condition fork means that the result value will be different. And it's worth when the variable has a data type change.

SimpleType

For C++, I made a new class added in each converted C++ project. The new class name is SimpleType.
This class is closing the gap about moving data type in loops and conditions.
For instance, any assigned variable during a loop or a condition creates a SimpleType object. All value change and all data type move are stored in that object. The class maintains an explicit data type and an union structure for the value.
Then, any assignment will check and convert or compute the value in the executable program.


Last edited Dec 21, 2014 at 7:22 PM by skercrow, version 7