Comments (3)
Working with heterogeneous collections is a pain in rust.. We could also provide a macro which simplifies the process for the user. (We may even want this earlier than 0.3.0
)
For example,
let values = mixed_value_array!(BasicValue, [
float_value,
int_value,
...
]);
If we do end up adding this macro, I'd strongly consider switching the current homogeneous function params from say, &[&BasicValue]
to &[BasicValueEnum]
since the former generally requires an extra heap allocation (unless you happen to have a fixed size of values on the stack, which probably isn't realistic) for the extra trait indirection which could be avoided.
Then, this macro could expand to something like let values: Vec<BasicValueEnum> = array.iter().map(|val| val.into()).collect()
. Might need associated type to derive BasicValueEnum
from BasicValue
, though.
from inkwell.
The example function!
macro you showed above would require the power brought by proc_macro
, but it can be achieved similarly using a Lisp-like syntax (like clap.rs) with the macro_rules
system.
Here's an example of doing dynamic code generation using this syntax: primitives.rs (note: it's part of a legacy compiler I wrote last year, the code is ugly in some places). The macro itself is defined here.
from inkwell.
Proc macros are probably fine; I don't expect to get to this issue before Macros 2.0 lands in stable(it seems pretty close: rust-lang/rust#38356), but who knows.
from inkwell.
Related Issues (20)
- Couldn't compile HOT 5
- Unable to Access Context Dynamically in LLVMManager: Seeking Alternative Approach HOT 2
- `InstructionValue::new` is `pub(crate)` instead of `pub` HOT 2
- Segfaults when builder is called without setting its position first HOT 5
- Add llvm-sys linkage flags
- Question: How to use LLVM `type`? HOT 5
- More examples? HOT 6
- Question: Is there a way to get the BasicValueEnum from the name of the instruction. HOT 6
- Question: What does `get_insert_block` returns. HOT 2
- Question: How can I get all defined structures? HOT 2
- Question: How to get the size of a type during LLVM generation? HOT 4
- Add `typos` to CI
- Create new fine-grained enum for `build_cast` HOT 1
- How to link library to jit? HOT 2
- Support llvm 17 HOT 1
- Add support for `global_ctor` HOT 4
- Add support for `global_ctor` HOT 3
- ORC support HOT 1
- Const struct member access HOT 1
- Segfault when using `module.create_jit_execution_engine()` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inkwell.