Move compile::visit mod to crate root
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
compile::{ctx::Ctx, error::*, ir, visit::*},
|
compile::{ctx::Ctx, error::*, ir},
|
||||||
syn::{ast::*, op::BinOp, span::*},
|
syn::{ast::*, op::BinOp, span::*},
|
||||||
|
visit::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
// basic block
|
// basic block
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod visit;
|
|
||||||
pub mod attrs;
|
pub mod attrs;
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod ctx;
|
pub mod ctx;
|
||||||
@@ -7,3 +6,47 @@ pub mod error;
|
|||||||
pub mod ir;
|
pub mod ir;
|
||||||
pub mod name;
|
pub mod name;
|
||||||
pub mod sym;
|
pub mod sym;
|
||||||
|
|
||||||
|
// question:
|
||||||
|
// where to insert root/builtin names
|
||||||
|
//
|
||||||
|
// Brainstorming:
|
||||||
|
// * Want to avoid initializing a GC during compile-time
|
||||||
|
// * Shared resources between compiler and VM:
|
||||||
|
// - tracked pointers (gc'd or otherwise)
|
||||||
|
// - a "constant" pointer API might be a good avenue to explore - e.g. relaxing
|
||||||
|
// constraints on Attrs to accept pointers as a source of data (maybe
|
||||||
|
// Attrs::new_unchecked)
|
||||||
|
// - I think there needs to be a new way to make an Attrs instance without GC involved
|
||||||
|
// - Main problem is how to get the "this" pointer for Attrs obj?
|
||||||
|
// - Maybe make a "ConstGc" or something like that, which never releases its
|
||||||
|
// references and is used for the core?
|
||||||
|
// - registered symbols (mutable)
|
||||||
|
// * Separate object pointers from GC pointers
|
||||||
|
// - GC pointer itself gets marked, and then marks all attributes?
|
||||||
|
// - Maybe use a visitor pattern for marking built-in objects?
|
||||||
|
// - TODO - try this
|
||||||
|
//
|
||||||
|
// impl Visit<StrObj> for Gc {
|
||||||
|
// type Out = ();
|
||||||
|
// fn visit(&mut self, acceptor: &A) -> Self::Out {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// other idea: eliminate IR and compile straight from AST to vm::Op
|
||||||
|
// IR pros and cons
|
||||||
|
//
|
||||||
|
// Disposition: keep IR since it's already there and helps with semantic translation
|
||||||
|
//
|
||||||
|
// PRO
|
||||||
|
// =
|
||||||
|
// * Compact representation
|
||||||
|
// * Easier to translate to VM ops
|
||||||
|
// * Can add IR layer at a later time
|
||||||
|
//
|
||||||
|
// CON
|
||||||
|
// =
|
||||||
|
// * Requires lots of complex resource sharing (GC, symbols, etc) for creating constants
|
||||||
|
// * Probably better in the long term for modification using IR mid-level
|
||||||
|
// * More natural LHS expression compilation with IR
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
compile::{ctx::Ctx, visit::*},
|
compile::ctx::Ctx,
|
||||||
obj::prelude::*,
|
obj::prelude::*,
|
||||||
syn::{ast::prelude::*, span::*},
|
syn::{ast::prelude::*, span::*},
|
||||||
|
visit::*,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![feature(unsize, coerce_unsized, new_uninit)]
|
#![feature(unsize, coerce_unsized, new_uninit)]
|
||||||
|
|
||||||
|
#[macro_use] mod visit;
|
||||||
mod compile;
|
mod compile;
|
||||||
mod mem;
|
mod mem;
|
||||||
mod obj;
|
mod obj;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub trait DefaultAccept<V: Visit<Self>>: Accept + Sized {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! default_visitor {
|
macro_rules! default_visitor {
|
||||||
($default:ident for $visitor:ty where Out = $out:ty) => {
|
($default:ident for $visitor:ty where Out = $out:ty) => {
|
||||||
impl crate::compile::visit::Visit<$default> for $visitor {
|
impl crate::visit::Visit<$default> for $visitor {
|
||||||
type Out = $out;
|
type Out = $out;
|
||||||
fn visit(&mut self, acceptor: &$default) -> Self::Out {
|
fn visit(&mut self, acceptor: &$default) -> Self::Out {
|
||||||
acceptor.default_accept(self)
|
acceptor.default_accept(self)
|
||||||
@@ -30,7 +30,7 @@ macro_rules! default_visitor {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! empty_visitor {
|
macro_rules! empty_visitor {
|
||||||
($default:ident for $visitor:ty) => {
|
($default:ident for $visitor:ty) => {
|
||||||
impl crate::compile::visit::Visit<$default> for $visitor {
|
impl crate::visit::Visit<$default> for $visitor {
|
||||||
type Out = ();
|
type Out = ();
|
||||||
fn visit(&mut self, _: &$default) -> Self::Out {}
|
fn visit(&mut self, _: &$default) -> Self::Out {}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ macro_rules! empty_visitor {
|
|||||||
|
|
||||||
macro_rules! impl_accept {
|
macro_rules! impl_accept {
|
||||||
($what:ident) => {
|
($what:ident) => {
|
||||||
impl crate::compile::visit::Accept for $what {
|
impl crate::visit::Accept for $what {
|
||||||
fn accept<V: Visit<Self>>(&self, visitor: &mut V) -> V::Out {
|
fn accept<V: Visit<Self>>(&self, visitor: &mut V) -> V::Out {
|
||||||
visitor.visit(self)
|
visitor.visit(self)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user