~lsof/cff

23f37d0c749742c51259d767fceae546ed551b06 — lemon 1 year, 8 months ago 88066fc master
use arena for interning types too
1 files changed, 3 insertions(+), 2 deletions(-)

M src/type.cff
M src/type.cff => src/type.cff +3 -2
@@ 108,14 108,15 @@ struct TypeTraits {
   }

   fn dup(ty *const Type) *const Type {
      let p *Type = xmalloc(sizeof Type);
      static arena Arena = {};
      let p *Type = Arena:allocf(&arena, sizeof Type, alignof Type);
      static id int = 0;
      *p = *ty;
      p.id = id++;
      switch p.u {
      case Fn *f;
        let params = f.params;
        f.params = (as(**const Type)xmalloc(params.#len * sizeof *Type))[0::params.#len];
        f.params = (as(**const Type)Arena:allocf(&arena, params.#len * sizeof *Type, alignof *Type))[0::params.#len];
        memcpy(f.params.#ptr, params.#ptr, params.#len * sizeof *Type);
      }
      return p;