C code gen: rename include block to header block
This commit is contained in:
parent
7dd6352760
commit
24f9a0f5b5
1 changed files with 22 additions and 22 deletions
|
@ -12,21 +12,21 @@ use {
|
|||
};
|
||||
|
||||
pub struct LdmcCTargetMorph {
|
||||
include_blocks: Vec< String >,
|
||||
include_dependencies: HashMap< MorphismType, usize >,
|
||||
active_includes: Vec< usize >,
|
||||
header_blocks: Vec< String >,
|
||||
header_dependencies: HashMap< MorphismType, usize >,
|
||||
active_headers: Vec< usize >,
|
||||
active_types: Vec< TypeTerm >,
|
||||
active_instantiations: Vec< LdmcPrimMorph >,
|
||||
active_morphisms: Vec< LdmcPrimMorph >,
|
||||
active_lenpfx_types: Vec< (TypeTerm, TypeTerm) >,
|
||||
typedefs: Vec< String >,
|
||||
macro_calls: Vec< String >
|
||||
}
|
||||
|
||||
impl LdmcCTargetMorph {
|
||||
pub fn add_required_include_block(&mut self, block: String) {
|
||||
let i = self.include_blocks.len();
|
||||
self.active_includes.push(i);
|
||||
self.include_blocks.push(block);
|
||||
pub fn add_required_header_block(&mut self, block: String) {
|
||||
let i = self.header_blocks.len();
|
||||
self.active_headers.push(i);
|
||||
self.header_blocks.push(block);
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
|
@ -34,18 +34,18 @@ impl LdmcCTargetMorph {
|
|||
include_dependencies: HashMap< MorphismType, usize >
|
||||
) -> Self {
|
||||
let mut m = LdmcCTargetMorph {
|
||||
include_blocks,
|
||||
include_dependencies,
|
||||
active_includes: Vec::new(),
|
||||
active_instantiations: Vec::new(),
|
||||
header_blocks: include_blocks,
|
||||
header_dependencies: include_dependencies,
|
||||
active_headers: Vec::new(),
|
||||
active_morphisms: Vec::new(),
|
||||
active_types: Vec::new(),
|
||||
active_lenpfx_types: Vec::new(),
|
||||
typedefs: Vec::new(),
|
||||
macro_calls: Vec::new()
|
||||
};
|
||||
|
||||
m.add_required_include_block(
|
||||
"/* default ldmc includes */
|
||||
m.add_required_header_block(
|
||||
"/* default ldmc header */
|
||||
#include <stdint.h>
|
||||
#define FUSE(morph, src, dst) { int result = morph(src,dst); if(result) return result; }
|
||||
|
||||
|
@ -111,8 +111,8 @@ impl LdmcCTargetMorph {
|
|||
morph: MorphismInstance<LdmcPrimMorph>,
|
||||
) -> Result<LdmcPrimMorph, ()> {
|
||||
let new_inst = self.bake_morphism(dict, morph)?;
|
||||
if ! self.active_instantiations.contains(&new_inst) {
|
||||
self.active_instantiations.push(new_inst.clone());
|
||||
if ! self.active_morphisms.contains(&new_inst) {
|
||||
self.active_morphisms.push(new_inst.clone());
|
||||
}
|
||||
|
||||
let ty = new_inst.get_type().strip_halo();
|
||||
|
@ -124,12 +124,12 @@ impl LdmcCTargetMorph {
|
|||
|
||||
pub fn into_c_source(mut self, dict: &mut impl TypeDict) -> String {
|
||||
let mut source = String::new();
|
||||
self.active_includes.dedup();
|
||||
self.active_headers.dedup();
|
||||
self.typedefs.dedup();
|
||||
self.macro_calls.dedup();
|
||||
|
||||
for i in self.active_includes {
|
||||
source.push_str( &self.include_blocks[i] );
|
||||
for i in self.active_headers {
|
||||
source.push_str( &self.header_blocks[i] );
|
||||
source.push('\n');
|
||||
}
|
||||
source.push('\n');
|
||||
|
@ -147,7 +147,7 @@ impl LdmcCTargetMorph {
|
|||
}
|
||||
source.push('\n');
|
||||
|
||||
for m in self.active_instantiations {
|
||||
for m in self.active_morphisms {
|
||||
source.push_str(&m.generate_instantiation(dict, &HashMap::new()).expect("cant create function"));
|
||||
}
|
||||
source
|
||||
|
@ -163,8 +163,8 @@ impl LdmcCTargetMorph {
|
|||
|
||||
match &morph_inst {
|
||||
MorphismInstance::Primitive { ψ, σ, morph } => {
|
||||
if let Some(i) = self.include_dependencies.get(&morph.get_type()) {
|
||||
self.active_includes.push(*i);
|
||||
if let Some(i) = self.header_dependencies.get(&morph.get_type()) {
|
||||
self.active_headers.push(*i);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue