-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
102 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::{ModuleItem, ModuleResolver, ValkyrieStructure}; | ||
use nyar_wasm::{StructureType, WasmBuilder, WasmSymbol, WasmType}; | ||
|
||
impl ModuleResolver { | ||
pub fn build_wasm(&self) -> WasmBuilder { | ||
let mut builder = WasmBuilder::default(); | ||
|
||
for item in self.items.values() { | ||
match item { | ||
ModuleItem::Imported(_) => {} | ||
ModuleItem::Structure(v) => builder.insert_type(WasmType::Structure(StructureType { | ||
symbol: WasmSymbol::from(v.name()), | ||
fields: Default::default(), | ||
span: Default::default(), | ||
})), | ||
} | ||
} | ||
builder | ||
} | ||
} | ||
|
||
impl ValkyrieStructure {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use nyar_error::FileSpan; | ||
use std::sync::Arc; | ||
use valkyrie_ast::{ExpressionKind, IdentifierNode}; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct FieldDefinition { | ||
pub(crate) symbol: Arc<str>, | ||
pub(crate) typing: Option<ExpressionKind>, | ||
pub(crate) optional: bool, | ||
pub(crate) span: FileSpan, | ||
} | ||
|
||
impl FieldDefinition { | ||
pub fn new(name: &IdentifierNode) -> Self { | ||
Self { symbol: Arc::from(name.name.as_str()), typing: None, optional: false, span: Default::default() } | ||
} | ||
pub fn name(&self) -> String { | ||
self.symbol.to_string() | ||
} | ||
pub fn set_type(&mut self, typing: ExpressionKind) { | ||
self.typing = Some(typing); | ||
} | ||
pub fn get_type(&self) -> Option<&ExpressionKind> { | ||
self.typing.as_ref() | ||
} | ||
pub fn get_optional(&self) -> bool { | ||
self.optional | ||
} | ||
pub fn set_optional(&mut self, optional: bool) { | ||
self.optional = optional; | ||
} | ||
pub fn get_span(&self) -> FileSpan { | ||
self.span | ||
} | ||
pub fn set_span(&mut self, span: FileSpan) { | ||
self.span = span; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1 @@ | ||
use super::*; | ||
|
||
mod codegen; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct FieldDefinition { | ||
symbol: Arc<str>, | ||
typing: Option<ExpressionKind>, | ||
optional: bool, | ||
span: FileSpan, | ||
} | ||
|
||
impl FieldDefinition { | ||
pub fn new(name: &IdentifierNode) -> Self { | ||
Self { symbol: Arc::from(name.name.as_str()), typing: None, optional: false, span: Default::default() } | ||
} | ||
pub fn name(&self) -> String { | ||
self.symbol.to_string() | ||
} | ||
pub fn set_type(&mut self, typing: ExpressionKind) { | ||
self.typing = Some(typing); | ||
} | ||
pub fn get_type(&self) -> Option<&ExpressionKind> { | ||
self.typing.as_ref() | ||
} | ||
pub fn get_optional(&self) -> bool { | ||
self.optional | ||
} | ||
pub fn set_optional(&mut self, optional: bool) { | ||
self.optional = optional; | ||
} | ||
pub fn get_span(&self) -> FileSpan { | ||
self.span | ||
} | ||
pub fn set_span(&mut self, span: FileSpan) { | ||
self.span = span; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters