mirror of
https://github.com/swc-project/swc.git
synced 2024-09-11 16:55:27 +03:00
merging is not simple
This commit is contained in:
parent
bddf3b972f
commit
f18f9b2c50
@ -11,6 +11,7 @@ use std::{
|
||||
|
||||
#[cfg(feature = "parking_lot")]
|
||||
use parking_lot::Mutex;
|
||||
use rustc_hash::FxHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
@ -116,10 +117,11 @@ impl Globals {
|
||||
pub fn merge(globals: Vec<Lrc<Globals>>) -> MergeResult {
|
||||
let mut hygiene_data = hygiene::HygieneData::new();
|
||||
let mut marks = vec![];
|
||||
let mut result = MergeResult::default();
|
||||
|
||||
for g in &globals {
|
||||
let g = g.hygiene_data.lock();
|
||||
hygiene_data.merge(&g);
|
||||
hygiene_data.merge(&g, &mut result);
|
||||
}
|
||||
|
||||
for g in &globals {
|
||||
@ -127,12 +129,14 @@ impl Globals {
|
||||
marks.extend(g.iter().cloned());
|
||||
}
|
||||
|
||||
MergeResult {}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MergeResult {}
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MergeResult {
|
||||
pub ctxts: FxHashMap<SyntaxContext, SyntaxContext>,
|
||||
}
|
||||
|
||||
better_scoped_tls::scoped_tls!(
|
||||
|
||||
|
@ -23,7 +23,7 @@ use std::{
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::GLOBALS;
|
||||
use super::{MergeResult, GLOBALS};
|
||||
use crate::{collections::AHashMap, EqIgnoreSpan};
|
||||
|
||||
/// A SyntaxContext represents a chain of macro expansions (represented by
|
||||
@ -327,12 +327,7 @@ impl HygieneData {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn merge(&mut self, other: &Self) {
|
||||
self.syntax_contexts
|
||||
.extend_from_slice(&other.syntax_contexts);
|
||||
self.markings
|
||||
.extend(other.markings.iter().map(|(k, v)| (*k, *v)));
|
||||
}
|
||||
pub(crate) fn merge(&mut self, other: &Self, result: &mut MergeResult) {}
|
||||
|
||||
fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
|
||||
GLOBALS.with(|globals| {
|
||||
|
Loading…
Reference in New Issue
Block a user