Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
func normalize_func(type: Type*): Type* {
key: char[];
num_params := alen(type.tfunc.params);
for (i := 0; i < num_params; i++) {
param := normalize(type.tfunc.params[i]);
acatn(key, (:char*)param, sizeof(param));
}
ret := normalize(type.tfunc.ret);
acatn(key, (:char*)ret, sizeof(ret));
normalized := agetn(normalized_funcs, key, alen(key));
if (!normalized) {
params: TypeFuncParam[];
for (i := 0; i < num_params; i++) {
apush(params, {type = normalize(type.tfunc.params[i])});
}
normalized = new Type{kind = TYPE_FUNC, tfunc = {params = params, ret = ret}};
aputn(normalized_funcs, key, alen(key), normalized);
}
return normalized;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.