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

Rewrite Compiler #23

Merged
merged 454 commits into from
May 24, 2023
Merged

Rewrite Compiler #23

merged 454 commits into from
May 24, 2023

Conversation

mertcandav
Copy link
Member

@mertcandav mertcandav commented May 24, 2023

Rewrite JuleC

This PR includes a redeveloped form of the compiler from scratch. Various enhancements and improvements are available. However, a number of problems have also been resolved.

The reason why the compiler was rewritten is undoubtedly because the code base is bad and difficult to maintain and add/improve features. While this is of course a relatively subjective concept, with the compiler re-development the source code is made more readable and easier to maintain.

Changes

  • Easy-to-maintain code.
  • Fix CI.
  • In the future, the appropriate infrastructure has been created so that it can be compiled to different code bases other than C++.
  • Check illegal cross cycles for variables, type aliases and structures.
  • Fixes to the type system.
  • Cpp-linked types are no longer compatible with the type to which they are directly linked.
  • The string data type cannot be used implicitly in the append or copy built-in functions for byte strings.
  • Functions that return multiple cannot be used as an implicit argument in another function's call.
  • It fixes a number of API issues.
  • It removes generic types from built-in functions and makes the types in generic functions implicit.
  • Fixed a bug in checking that the function returns on every possible branch.
  • Removed generic types from generated C++ code output.
  • Fix type checking for constant expressions.
  • Fix generic typed functions and structures.
  • Remove type-aliases from generated object code.

Listed above are the main changes. The code base has been almost completely revamped and improved. However, a few features that have been removed may be reimplemented at a later time. These are not permanent removals.

Additionally, this PR doesn't fixes all noticed issues.
However, most of the issues do not directly affect the main subject of PR.

Cycles

One of the things that the old compiler doesn't do or does is superficial is the detection of illegal cycles. This new compiler; Adds full illegal cycle checking for type aliases, variables, and structs. The order of related definitions in the source code may be completely different, but in code generation they are generated sequentially, in an order that they follow their dependencies. Also, type aliases have been removed from the generated source code, using direct types instead.

Generic Types

Generic types are handled in completely different ways. In the old approach, C++ generic types were also used in the codes created for the C++ code base. Obviously, this brought with it many problems. For example, although some types were suitable for Duck Typing, their functioning in C++ was not the same as other types. This actually paved the way for code generated in situations like Duck Typing to potentially cause bugs.

In the new approach, the generated C++ code is handled completely free of generic types. Each unique type combination handles differently and generates code differently. Each combination uses the custom code base that has been checked and built for itself. For functions and structures that use generic types, this means generating unique code for each combination.

@mertcandav mertcandav added documentation Improvements or additions to documentation compiler/runtime Related with runtime proposal A proposal for new feature or changings compiler Related with compiler/compile-time labels May 24, 2023
@mertcandav mertcandav merged commit 905bec5 into master May 24, 2023
@mertcandav mertcandav removed the proposal A proposal for new feature or changings label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Related with runtime compiler Related with compiler/compile-time documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant