assyrianic / Tagha

Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
MIT License
124 stars 8 forks source link

Make all jump labels local? #42

Closed assyrianic closed 5 years ago

assyrianic commented 5 years ago

Currently, labels in the human-readable bytecode are not localized but global.

If you have two procedure implementations and both have a label called .exit then the assembler will error out that it's a redefinition. Here's a code example of what I mean:

%func1: {
.exit:
}

%func2: {
.exit:  ; <-- throws error because redefinition.
}

This shouldn't happen because jump labels are entirely local and, given that there's no access to the instruction pointer register, there's no way that a direct jump from one function to another's code space can occur anyway.