• Daniel Clifford's avatar
    [torque]: Implement Generics for Builtins and Macros · 3d2cb0b4
    Daniel Clifford authored
    Including specialization, e.g.:
    
      // Declare parameterized generic
      macro GenericMacroTest<T: type>(param: T): Object {
        return Undefined;
      }
    
      // Declare specialization of generic
      GenericMacroTest<Object>(param: Object): Object {
        return param;
      }
    
      ...
      assert(GenericMacroTest<Smi>(0) == Undefined);
      assert(GenericMacroTest<Smi>(1) == Undefined);
      assert(GenericMacroTest<Object>(Null) == Null);
      assert(GenericMacroTest<Object>(False) == False);
      ...
    
    Known issue: specialization doesn't rigorously checked to verify
    that specialization signature precisely matches generic declaration.
    
    Change-Id: I9d9d96da4c5c8c9a76550844680e9e133a5edaed
    Reviewed-on: https://chromium-review.googlesource.com/1043986
    Commit-Queue: Daniel Clifford <danno@chromium.org>
    Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#53203}
    3d2cb0b4
declaration-visitor.cc 12.6 KB