Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

[Lang Enhancement Proposal] Implement PblType_T, PblTypeList_T and file scope type tracking (dynamic type checking and conversion) #67

Open
3 tasks
Tracked by #69
Luna-Klatzer opened this issue Nov 12, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request language Core language issue, change or idea

Comments

@Luna-Klatzer
Copy link
Member

Luna-Klatzer commented Nov 12, 2021

Affected area by change:

  • Language Syntax: yes
  • Language Library (Parac Base Library): yes
  • Compiler: yes
  • Pre-Processor: no
  • Documentation: yes

Short Introduction and Summary

Currently, there are two proposals in this repo (#65 and #66) both aiming to provide new types, which would allow for the implementation of a compiler and pbl-managed type-list, which would keep track of all types and allow for dynamic initialisation, conversion and checking, by saving meta-data and allowing the user to "copy" from that to create new types.

Is your request related to a problem? Please describe.

Describe the solution you'd like

Implement the new type PblTypeMeta_T, which would track the functionality and meta-data of a type itself. That type should then be automatically saved in the global dictionary at runtime, e.g. right at runtime start.

Signatures:

  • The type list itself:
    struct PblTypeList {
      /// @brief The actual allocated length
      int alloc_len;
      /// @brief The amount of items stored
      int t_amount;
      /// @brief The dictionary items
      PblType_T* t_items;
    };
  • Creating a new type signature type:
    PblType_T* PblCreateNewType(size_t size, void* type_template, char* name, bool user_defined);
  • Adding a new type to the type list:
    PblVoid_T PblAddTypeToTypeList(const PblType_T* type)
  • Macro for defining a local type initialisation function that shall run at startup:
    #define INIT_LOCAL_TYPES                                                                                               \
    __attribute__((unused)) __attribute__((constructor))                                                             \
    __attribute__((deprecated("Compiler-Only Function - User Call Invalid!")))                           \
    static void PBL_CONSTRUCTOR_TYPES_INIT(void)
    This may be used like this:
    INIT_LOCAL_TYPES {
      PblAddTypeToTypeList(PblCreateNewType(...));
    };

Describe alternatives you've considered

None.

Additional context

@Luna-Klatzer Luna-Klatzer added the enhancement New feature or request label Nov 12, 2021
@Luna-Klatzer Luna-Klatzer self-assigned this Nov 12, 2021
@Luna-Klatzer Luna-Klatzer pinned this issue Dec 9, 2021
@Luna-Klatzer Luna-Klatzer added this to the Road to Hello World milestone Dec 9, 2021
@Luna-Klatzer Luna-Klatzer changed the title [Lang Enhancement Proposal] Implement PblTypeMeta_T and global type tracking (dynamic type checking and conversion) [Lang Enhancement Proposal] Implement PblTypeMeta_T and file scope type tracking (dynamic type checking and conversion) Jan 21, 2022
@Luna-Klatzer
Copy link
Member Author

Luna-Klatzer commented Jan 21, 2022

Important changes in implementation:

  • Types will now have an additional variable Pbl_T_SIGNATURE, which will store the pointer to the global type dictionary entry and allow that types don't have to search by their name for the entry.
  • This specifically also means that the type dict will be more like a list storing all initialised types. As such, the PblTypeDict_T will be renamed to simply PblTypeList_T and furthermore handled as a list rather than a dictionary.
  • The type tracking will be localised to the file, to avoid having to deal with name mangling. This also means that when including types from a header to a file, the local mangling will be applied (if necessary)

@Luna-Klatzer
Copy link
Member Author

Most of the functionality has been now implemented in 88286b7f60f8079d74d0c7bb966777d2f9b20110

@Luna-Klatzer Luna-Klatzer reopened this Jan 21, 2022
@Luna-Klatzer Luna-Klatzer changed the title [Lang Enhancement Proposal] Implement PblTypeMeta_T and file scope type tracking (dynamic type checking and conversion) [Lang Enhancement Proposal] Implement PblType_T, PblTypeList_T and file scope type tracking (dynamic type checking and conversion) Jan 28, 2022
@Luna-Klatzer Luna-Klatzer added the language Core language issue, change or idea label Apr 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request language Core language issue, change or idea
Projects
None yet
Development

No branches or pull requests

1 participant