L1VM - linter

I did write a linter to check function call arguments. If there is a type or number of arguments mismatch, it will show an error message. The needed setting is in a comment. To make this backwards compatible with the compiler. The compiler will ignore it.

Here is an example: “hello-add.l1com”:

// hello-add.l1com - with the new linter args
#include <intr.l1h>
// this is the function declaration for the l1vm-linter:
// it has two int64 numbers as arguments:
//
// (func args add int64 int64)
//
// set the return variable type:
// (return args add int64)
(main func)
    #var ~ main

    (set int64 1 zero 0)
    (set int64 1 x~ 23)
    (set int64 1 y~ 7)
    (set int64 1 ret~ 0)

    (x~ y~ :add !) (ret~ stpop)
    print_i (ret~)
    print_n

    exit (zero)
(funcend)
(add func)
   #var ~ add

   (set int64 1 x~ 0)
   (set int64 1 y~ 0)
   (set int64 1 ret~ 0)

   (y~ x~ stpop)
   {ret~ = x~ + y~}
   (ret~ stpush) (return)
(funcend)

The line:

// (func args add int64 int64)

sets the two arguments of the function add to two int64 integer numbers. On a function call of “add” the arguments are checked if they match. If the number of arguments or the types don’t match you will get an error message. This finds errors at compile time.

Have fun!