Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mangling rules #93

Open
vdka opened this issue Oct 30, 2017 · 0 comments
Open

Update mangling rules #93

vdka opened this issue Oct 30, 2017 · 0 comments

Comments

@vdka
Copy link
Contributor

vdka commented Oct 30, 2017

File mangling

The file the compiler was invoked upon (known as the invocation file) has no mangle prefix for it's top level entities

Every other file is mangled with it's path relative to the invocation file.
eg:
main.kai (invocation file)

#import "math.kai"
// mangled: `main`
main :: fn() -> void {...}

math.kai

mangled: `math.lerp`
lerp :: fn() -> void {...}

Function Scopes

Function scopes only mangle compile time entities and anonymous functions.
eg:

main :: fn() -> void {
    // mangled name = `main.map`
    sort :: fn(in: []int, predicate: (int, int) -> bool) -> void { ... }
    // param #2's anon func would mangle too `.fn` (prefix is ditched)
    sort(myArray, fn(x, y: int) -> bool { ... })
}

Type Scopes

Type Scopes mangle their entities using the current scope prefix + the name of the type.
eg:

Person :: struct {
    firstName, lastName: string
    // mangled name = `Person.new`
    new :: fn(first, last: string) -> void { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant