Make whole Schema available when compiling
This commit is contained in:
parent
c4afc49646
commit
87227b5623
|
@ -29,6 +29,7 @@ pub struct ModuleContext<'m> {
|
|||
pub typedefs: Vec<Item>,
|
||||
pub functiondefs: Vec<Item>,
|
||||
pub mode: Option<ModuleContextMode>,
|
||||
pub schema: &'m Schema,
|
||||
}
|
||||
|
||||
pub struct FunctionContext<'a, 'm> {
|
||||
|
@ -55,14 +56,19 @@ lazy_static! {
|
|||
}
|
||||
|
||||
impl<'m> ModuleContext<'m> {
|
||||
pub fn new(config: &'m CompilerConfig, module_path: &ModulePath) -> Self {
|
||||
pub fn new(
|
||||
config: &'m CompilerConfig,
|
||||
module_path: &ModulePath,
|
||||
schema: &'m Schema,
|
||||
) -> Self {
|
||||
ModuleContext {
|
||||
module_path: module_path.to_owned(),
|
||||
config: config,
|
||||
config,
|
||||
literals: Map::new(),
|
||||
typedefs: Vec::new(),
|
||||
functiondefs: Vec::new(),
|
||||
mode: None,
|
||||
schema,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,12 @@ fn write_if_changed(output_path: &PathBuf, contents: &[u8]) -> io::Result<()> {
|
|||
f.write_all(contents)
|
||||
}
|
||||
|
||||
impl Schema {
|
||||
pub fn has_embedded_type(&self) -> bool {
|
||||
self.embedded_type != EmbeddedTypeName::False
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compile(config: &CompilerConfig) -> io::Result<()> {
|
||||
for (k, v) in config.bundle.iter() {
|
||||
let mut output_path = config.output_dir.clone();
|
||||
|
@ -131,7 +137,7 @@ pub fn compile(config: &CompilerConfig) -> io::Result<()> {
|
|||
let module_name = names::render_modname(&module_name);
|
||||
output_path.set_file_name(format!("{}.rs", module_name));
|
||||
DirBuilder::new().recursive(true).create(output_path.parent().unwrap())?;
|
||||
let mut m = context::ModuleContext::new(config, &ModulePath(k.clone()));
|
||||
let mut m = context::ModuleContext::new(config, &ModulePath(k.clone()), v);
|
||||
|
||||
let mut modes: Vec<context::ModuleContextMode> =
|
||||
vec![context::ModuleContextMode::TargetAny];
|
||||
|
|
Loading…
Reference in New Issue