MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / add_function_flags

Method add_function_flags

crates/wit-bindgen/src/config.rs:109–149  ·  view source on GitHub ↗
(
        &mut self,
        resolve: &Resolve,
        key: Option<&WorldKey>,
        name: &str,
        base: &mut FunctionFlags,
    )

Source from the content-addressed store, hash-verified

107 }
108
109 fn add_function_flags(
110 &mut self,
111 resolve: &Resolve,
112 key: Option<&WorldKey>,
113 name: &str,
114 base: &mut FunctionFlags,
115 ) {
116 let mut apply_rules = |name: &str, is_exact: bool| {
117 for rule in self.rules.iter_mut() {
118 if name != rule.filter {
119 continue;
120 }
121 if !is_exact && rule.flags.contains(FunctionFlags::EXACT) {
122 continue;
123 }
124 rule.used = true;
125 *base |= rule.flags;
126
127 // only the first rule is used.
128 return true;
129 }
130
131 false
132 };
133 match key {
134 Some(key) => {
135 for (lookup, projection) in lookup_keys(resolve, key, LookupItem::Name(name)) {
136 if apply_rules(&lookup, projection.is_empty()) {
137 return;
138 }
139 }
140 }
141 None => {
142 if apply_rules(name, true) {
143 return;
144 }
145 }
146 }
147
148 *base |= self.default;
149 }
150
151 pub(crate) fn assert_all_rules_used(&self, kind: &str) -> Result<()> {
152 let mut unused = Vec::new();

Callers 2

flagsMethod · 0.80
resource_drop_flagsMethod · 0.80

Calls 5

lookup_keysFunction · 0.85
NameClass · 0.85
iter_mutMethod · 0.45
containsMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected