Last active
          February 25, 2019 17:10 
        
      - 
      
 - 
        
Save pervognsen/f3783c756c1dfd600b104dcb1df8204d to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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