PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/sys/java/fanx/emit/FClassEmit.java

https://bitbucket.org/bedlaczech/fan-1.0
Java | 64 lines | 34 code | 8 blank | 22 comment | 4 complexity | a332238d15b3e703f362a98bbfbd0263 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. //
  2. // Copyright (c) 2006, Brian Frank and Andy Frank
  3. // Licensed under the Academic Free License version 3.0
  4. //
  5. // History:
  6. // 19 Mar 06 Brian Frank Creation
  7. //
  8. package fanx.emit;
  9. import java.util.*;
  10. import fan.sys.*;
  11. import fanx.fcode.*;
  12. import fanx.util.*;
  13. /**
  14. * FClassEmit emits a normal class type.
  15. */
  16. public class FClassEmit
  17. extends FTypeEmit
  18. implements FConst
  19. {
  20. //////////////////////////////////////////////////////////////////////////
  21. // Constructor
  22. //////////////////////////////////////////////////////////////////////////
  23. public FClassEmit(Type parent, FType type)
  24. {
  25. super(parent, type);
  26. }
  27. //////////////////////////////////////////////////////////////////////////
  28. // Overrides
  29. //////////////////////////////////////////////////////////////////////////
  30. protected String base()
  31. {
  32. // if the base is a generic instance, then this must be a closure
  33. // func type (since we can't subclass List or Map). We subclass
  34. // from one of the canned Func.Indirect inner classes.
  35. FTypeRef ref = pod.typeRef(type.base);
  36. if (ref.isGenericInstance())
  37. {
  38. this.funcType = (FuncType)Type.find(ref.signature, true);
  39. int paramCount = funcType.params.length;
  40. if (paramCount > Func.MaxIndirectParams)
  41. return "fan/sys/Func$IndirectX";
  42. else
  43. return "fan/sys/Func$Indirect" + paramCount;
  44. }
  45. else
  46. {
  47. String base = jname(type.base);
  48. if (base.equals("java/lang/Object")) return "fan/sys/FanObj";
  49. if (base.equals("fan/sys/Type")) return "fan/sys/ClassType";
  50. return base;
  51. }
  52. }
  53. //////////////////////////////////////////////////////////////////////////
  54. // Fields
  55. //////////////////////////////////////////////////////////////////////////
  56. }