Skip to content

Commit

Permalink
Rename system -> built_ins in internal binding functions and types
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Feb 10, 2025
1 parent 605c866 commit 7addd09
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions crates/metaslang/bindings/generated/public_api.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions crates/metaslang/bindings/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(crate) struct ExtendedStackGraph<KT: KindTypes + 'static> {
#[derive(Clone)]
pub enum FileDescriptor {
User(String),
System(String),
BuiltIns(String),
}

#[derive(Debug)]
Expand All @@ -62,7 +62,7 @@ impl FileDescriptor {
pub(crate) fn as_string(&self) -> String {
match self {
Self::User(path) => format!("user:{path}"),
Self::System(path) => format!("system:{path}"),
Self::BuiltIns(path) => format!("built-ins:{path}"),
}
}

Expand All @@ -72,8 +72,8 @@ impl FileDescriptor {
.map(|path| FileDescriptor::User(path.into()))
.or_else(|| {
value
.strip_prefix("system:")
.map(|path| FileDescriptor::System(path.into()))
.strip_prefix("built-ins:")
.map(|path| FileDescriptor::BuiltIns(path.into()))
})
.ok_or(FileDescriptorError)
}
Expand All @@ -86,12 +86,12 @@ impl FileDescriptor {
pub fn get_path(&self) -> &str {
match self {
Self::User(path) => path,
Self::System(path) => path,
Self::BuiltIns(path) => path,
}
}

pub fn is_system(&self) -> bool {
matches!(self, Self::System(_))
pub fn is_built_ins(&self) -> bool {
matches!(self, Self::BuiltIns(_))
}

pub fn is_user(&self) -> bool {
Expand Down Expand Up @@ -138,12 +138,12 @@ impl<KT: KindTypes + 'static> BindingGraphBuilder<KT> {
_ = self.add_file_internal(file, tree_cursor);
}

pub fn build_system_file(
pub fn build_built_ins_file(
&mut self,
file_path: &str,
cursor: Cursor<KT>,
) -> FileGraphBuilder<'_, KT> {
let file_kind = FileDescriptor::System(file_path.into());
let file_kind = FileDescriptor::BuiltIns(file_path.into());
let file = self.graph.get_or_create_file(&file_kind);
FileGraphBuilder::new(&mut self.graph, file, cursor)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/metaslang/bindings/src/graph/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<KT: KindTypes + 'static> Definition<KT> {

pub fn name_location(&self) -> BindingLocation<KT> {
match self.get_file() {
FileDescriptor::System(_) => BindingLocation::built_in(),
FileDescriptor::BuiltIns(_) => BindingLocation::built_in(),
FileDescriptor::User(file_id) => {
BindingLocation::user_file(file_id, self.get_cursor().to_owned())
}
Expand All @@ -30,7 +30,7 @@ impl<KT: KindTypes + 'static> Definition<KT> {

pub fn definiens_location(&self) -> BindingLocation<KT> {
match self.get_file() {
FileDescriptor::System(_) => BindingLocation::built_in(),
FileDescriptor::BuiltIns(_) => BindingLocation::built_in(),
FileDescriptor::User(file_id) => {
BindingLocation::user_file(file_id, self.get_definiens_cursor().to_owned())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/metaslang/bindings/src/graph/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<KT: KindTypes + 'static> Reference<KT> {

pub fn location(&self) -> BindingLocation<KT> {
match self.get_file() {
FileDescriptor::System(_) => BindingLocation::built_in(),
FileDescriptor::BuiltIns(_) => BindingLocation::built_in(),
FileDescriptor::User(file_id) => {
BindingLocation::user_file(file_id, self.get_cursor().to_owned())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn add_built_ins(
.unwrap();
let empty_cursor = Rc::clone(&empty_node).create_cursor(TextIndex::ZERO);

let mut file_builder = builder.build_system_file("built_ins.sol", empty_cursor);
let mut file_builder = builder.build_built_ins_file("built_ins.sol", empty_cursor);

let root_node = file_builder.root_node();
// __SLANG_SOLIDITY_BUILT_INS_SCOPE_GUARD__ keep in sync with binding rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn build_report_for_part<'a>(
}
1 => {
let definition = definitions.first().unwrap();
if definition.get_file().is_system() {
if definition.get_file().is_built_ins() {
"ref: built-in".to_string()
} else {
let def_id = all_definitions
Expand All @@ -202,7 +202,7 @@ fn build_report_for_part<'a>(
let ref_labels = definitions
.iter()
.filter_map(|definition| {
if definition.get_file().is_system() {
if definition.get_file().is_built_ins() {
Some("built-in".to_string())
} else {
all_definitions
Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/testing/sanctuary/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn run_bindings_check(
let binding_graph = create_bindings(version, source_id, output)?;

for reference in binding_graph.all_references() {
if reference.get_file().is_system() {
if reference.get_file().is_built_ins() {
// skip built-ins
continue;
}
Expand Down

0 comments on commit 7addd09

Please sign in to comment.