constructor.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. function MixAutoAndManualInitFields(){
  11. this.iAuto = 0;
  12. this.iManual = 123;
  13. this.$rAuto = new T();
  14. this.$rManual = new RecordWithParamConstructor(345);
  15. this.setManual = 8;
  16. this.stringAuto = '';
  17. }
  18. function UsingSelfInFieldsInit(){
  19. this.i1 = 123;
  20. this.i2 = this.i1;
  21. }
  22. function FieldInitAndBody(){
  23. this.i = 1;
  24. this.i = 2;
  25. }
  26. function T(){
  27. }
  28. function Derived(){
  29. T.call(this);
  30. }
  31. RTL$.extend(Derived, T);
  32. function RecordWithField(){
  33. this.i = 0;
  34. }
  35. function RecordWithFieldDerived(){
  36. T.call(this);
  37. }
  38. RTL$.extend(RecordWithFieldDerived, T);
  39. function passAsArgument(o/*T*/){
  40. }
  41. function RecordWithParamConstructor(a/*INTEGER*/){
  42. }
  43. function DerivedRecordWithParamConstructor(){
  44. RecordWithParamConstructor.call(this, 123);
  45. }
  46. RTL$.extend(DerivedRecordWithParamConstructor, RecordWithParamConstructor);
  47. function InitializeField(){
  48. this.i = 123;
  49. }
  50. function InitializeRecordField(){
  51. this.$r = new RecordWithParamConstructor(123);
  52. }
  53. function InitializeMangledField(){
  54. this.constructor$ = 123;
  55. this.prototype$ = true;
  56. }
  57. passAsArgument(new T());
  58. var r = new T();
  59. var i = new RecordWithField().i;
  60. var rParam = new RecordWithParamConstructor(123);
  61. }();