-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement macro host generate_code, find proc_macro attributes
commit-id:e59370d2
- Loading branch information
Showing
3 changed files
with
157 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::core::Package; | ||
use cairo_lang_defs::patcher::PatchBuilder; | ||
use cairo_lang_syntax::node::db::SyntaxGroup; | ||
use cairo_lang_syntax::node::{ast, TypedSyntaxNode}; | ||
use scarb_macro_interface::plugin::{ProcMacroResult, TokenStream}; | ||
use std::fmt::Debug; | ||
|
||
pub trait FromItemAst { | ||
fn from_item_ast(db: &dyn SyntaxGroup, item_ast: ast::ModuleItem) -> Self; | ||
} | ||
|
||
impl FromItemAst for TokenStream { | ||
fn from_item_ast(db: &dyn SyntaxGroup, item_ast: ast::ModuleItem) -> Self { | ||
let mut builder = PatchBuilder::new(db); | ||
builder.add_node(item_ast.as_syntax_node()); | ||
let cairo = builder.code.clone(); | ||
Self::from(cairo) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ProcMacroInstance {} | ||
|
||
impl ProcMacroInstance { | ||
pub fn new(_package: Package) -> Self { | ||
// Load shared library | ||
// TODO(maciektr): Implement | ||
Self {} | ||
} | ||
|
||
pub(crate) fn generate_code(&self, _token_stream: TokenStream) -> ProcMacroResult { | ||
// Apply expansion to token stream. | ||
// TODO(maciektr): Implement | ||
ProcMacroResult::Leave | ||
} | ||
} |
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,3 +1,5 @@ | ||
mod ffi; | ||
mod host; | ||
|
||
pub use ffi::*; | ||
pub use host::*; |