lurscher
lurscher

Reputation: 26963

dependencies between source and error runtime component

I have an annoying dependency problem between components, and i would like to hear several ways to resolve it.

Basically i have 3 components that depend almost acyclically from each other, except for a small dependency between the first and the last component. Concretely, this is a JIT compiler but hopefully it is a widely occuring type of abstract dependency which may happen in other circumstances.

Component dependency diagram

The components are basically in sequence of flow dependency; source/AST generation, code generation and runtime. As it is clear from the diagram, errors generated at runtime should be able to communicate Ids that can be correlated to source location items. The tricky part is that this Id is not necessarily an integer type (although it can be). Until now, SourceItemID was a type internal to the Source component, but now it seems it needs to be defined outside of it.

What would be optimal patterns to use here? I was thinking in maybe templatizing the runtime error type with the desired Source location id.

Upvotes: 2

Views: 81

Answers (1)

Mat
Mat

Reputation: 206833

The simplest solution is to define all the types and common behavior that is used by your modules in an independent unit (possibly a single header), that all the real processing units use.

For minimum overhead/headaches and compatibility issues (these shared types could be useful elsewhere at some point for communication with other apps/plugins/whatever), try to keep those types POD if you can.

"Templatizing" things is not trivial. It is very powerful and expressive, but if you're looking at removing dependencies, my opinion is: try to see if you can make things simpler first.

Upvotes: 1

Related Questions