constructor.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var RTL$ = {
  2. extend: function (cons, base){
  3. function Type(){}
  4. Type.prototype = base.prototype;
  5. cons.prototype = new Type();
  6. cons.prototype.constructor = cons;
  7. }
  8. };
  9. var m = function (){
  10. RTL$.extend(Derived, T);
  11. RTL$.extend(RecordWithFieldDerived, T);
  12. RTL$.extend(DerivedRecordWithParamConstructor, RecordWithParamConstructor);
  13. RTL$.extend(DerivedRecordWithParamConstructorBaseWithNoParameters, T);
  14. function DerivedRecordWithParamConstructorWithoutConstructor(){
  15. RecordWithParamConstructor.apply(this, arguments);
  16. }
  17. RTL$.extend(DerivedRecordWithParamConstructorWithoutConstructor, RecordWithParamConstructor);
  18. function MixAutoAndManualInitFields(){
  19. this.iAuto = 0;
  20. this.iManual = 123;
  21. this.$rAuto = new T();
  22. this.$rManual = new RecordWithParamConstructor(345);
  23. this.setManual = 8;
  24. this.stringAuto = '';
  25. }
  26. function UsingSelfInFieldsInit(){
  27. this.i1 = 123;
  28. this.i2 = this.i1;
  29. }
  30. function FieldInitAndBody(){
  31. this.i = 1;
  32. this.i = 2;
  33. }
  34. function T(){
  35. }
  36. function Derived(){
  37. T.call(this);
  38. }
  39. function RecordWithField(){
  40. this.i = 0;
  41. }
  42. function RecordWithFieldDerived(){
  43. T.call(this);
  44. }
  45. function passAsArgument(o/*T*/){
  46. }
  47. function RecordWithParamConstructor(a/*INTEGER*/){
  48. }
  49. function DerivedRecordWithParamConstructor(){
  50. RecordWithParamConstructor.call(this, 123);
  51. }
  52. function DerivedRecordWithParamConstructorBaseWithNoParameters(a/*INTEGER*/){
  53. T.call(this);
  54. }
  55. function InitializeField(){
  56. this.i = 123;
  57. }
  58. function InitializeRecordField(){
  59. this.$r = new RecordWithParamConstructor(123);
  60. }
  61. function InitializeMangledField(){
  62. this.constructor$ = 123;
  63. this.prototype$ = true;
  64. }
  65. passAsArgument(new T());
  66. var r = new T();
  67. var i = new RecordWithField().i;
  68. var rParam = new RecordWithParamConstructor(123);
  69. var derived = new DerivedRecordWithParamConstructorWithoutConstructor(123);
  70. }();