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

Template type instances generated in separate modules do not generate include statements in C code #985

Open
alexnask opened this issue Mar 18, 2016 · 1 comment

Comments

@alexnask
Copy link
Collaborator

Here is an example in some code I've been writing:

UnsafeArray.ooc

UnsafeArray: cover template <T> {
    data: T*
    length: Int

    init: func@ (=length) {
        data = gc_malloc(T size * length)
    }

    operator [] (i: Int) -> T {
        data[i]
    }

    operator@ []= (i: Int, t: T) -> T {
        data[i] = t
    }
}

Bitmap.ooc

import ../UnsafeArray

RgbColor: cover {
    r, g, b: UInt8

    init: func@ (=r, =g, =b)
}

Bitmap: class {
    width, height: Int
    data: UnsafeArray<RgbColor>

    pixelCount ::= width * height
    /* ...  */
}

This piece of code generates invalid C code because the generated template instance does not have access to RgbColor's declaration.

Rock should automatically deduce what additional imports are needed and add them to the template type's module.

@alexnask
Copy link
Collaborator Author

Temporary fix is obviously adding imports manually (e.g. import Bitmap in this example)

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