I'm trying to implement a toy language with dynamic typing, i.e., variables do not have types, only values do, and every variable needs to be declared before being used. For example, the code might look like var x; x = 3; x = 'a';
. Furthermore, I want to compile this toy language to native code instead of running it in some virtual machine.
Currently, I've generated an AST and I am going to compile the AST to LLVM IR using LLVM C++ APIs. The question is, what kind of IR should I generate for
- Variable Declaration (with or without initial value, like
var x;
orvar y = 3.4;
- Variable Access (like
a
inc = a + 1
)