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

Improve and generalize sized type checking #5

Open
zanellia opened this issue May 6, 2020 · 0 comments
Open

Improve and generalize sized type checking #5

zanellia opened this issue May 6, 2020 · 0 comments

Comments

@zanellia
Copy link
Owner

zanellia commented May 6, 2020

As of now sized type checking is carried out in a rather case-specific fashion. At some point, the typed_record (https://github.com/zanellia/prometeo/blob/master/prometeo/cgen/code_gen_c.py#L324) and the var_dim_record (https://github.com/zanellia/prometeo/blob/master/prometeo/cgen/code_gen_c.py#L328) generated during the static analysis should be merged into a single dictionary and they should support any valid sized type e.g

n : dims = 10
A : pmat = pmat(n,n)
class ClassA():
    A : pmat = pmat(n,n)
class ClassB():
    A : pmat = pmat(n,n)
    B : ClassA = ClassA()

As of now 1) and 2) work fine, but to support 3) and more sophisticated user-defined sized types the code needs some restructuring.

In particular, if we analyze

from prometeo import *

n : dims = 10

class ClassA():
    A : pmat = pmat(n,n)

def main() -> int:
    A : pmat = pmat(n,n)
    return 0

it will result in the following typed_record:

{
    "global": {
        "n": "dims"
    },
    "global@ClassA": {
        "A": "pmat"
    },
    "global@main": {
        "A": "pmat"
    }
}

and the following var_dim_record:

{
    "global": {},
    "global@ClassA": {
        "A": [
            "n",
            "n"
        ]
    },
    "global@main": {
        "A": [
            "n",
            "n"
        ]
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant