zanellia / prometeo

An experimental Python-to-C transpiler and domain specific language for embedded high-performance computing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class and method meta-information definition

zanellia opened this issue · comments

This is part of a brainstorming with the development team on how to define meta-information structures for classes and methods within prometeo's parser. Rough draft:

Python example

class ClassA:
    def __init__(self):
        self.attr1 : int = 0

    def method1(self, arg1 : int) -> int:
        return self.attr1 + arg1

class ClassB:
    def __init__(self):
        self.attr1 : int = 0
        self.attr2 : ClassA = ClassA()

    def method1(self, arg1 : int) -> ClassA:
        return self.attr2

Meta-information:

[
    'ClassA' : [
        'constructor_args' : 
            [('self', 'self')],
        'attributes' : 
            [('attr1', 'int', 0)],
        'methods' : [
            'method1' : 
                'args' : 
                [('self','self'), ('arg1', 'int')],
                'return_type' : 'int'
        ]
    ]
]

[
    'ClassB' : [
        'constructor_args' : 
            [('self', 'self')],
        'attributes' : 
            [('attr1', 'int', 0), ('attr2', 'ClassA', 'None')],
        'methods' : [
            'method1' : 
                'args' : 
                [('self','self'), ('arg1', 'int')],
                'return_type' : 'ClassA'
        ]
    ]
]

Addressed in #8.