浏览代码

more strict code generation

Vladislav Folts 10 年之前
父节点
当前提交
ff4777eccb
共有 5 个文件被更改,包括 18 次插入10 次删除
  1. 二进制
      bin/compiled.zip
  2. 4 1
      src/context.js
  3. 5 0
      src/eberon/eberon_context.js
  4. 7 7
      test/expected/eberon/method.js
  5. 2 2
      test/expected/eberon/modules.js

二进制
bin/compiled.zip


+ 4 - 1
src/context.js

@@ -404,6 +404,9 @@ exports.ProcDecl = ChainedContext.extend({
     _prolog: function(){
     _prolog: function(){
         return "\nfunction " + this.__id.id() + "(";
         return "\nfunction " + this.__id.id() + "(";
     },
     },
+    _epilog: function(){
+        return "";
+    },
     _beginBody: function(){
     _beginBody: function(){
         this.codeGenerator().openScope();
         this.codeGenerator().openScope();
     },
     },
@@ -460,7 +463,7 @@ exports.ProcDecl = ChainedContext.extend({
         this.__returnParsed = true;
         this.__returnParsed = true;
     },
     },
     endParse: function(){
     endParse: function(){
-        this.codeGenerator().closeScope("");
+        this.codeGenerator().closeScope(this._epilog());
         this.root().popScope();
         this.root().popScope();
 
 
         var result = this.__type.result();
         var result = this.__type.result();

+ 5 - 0
src/eberon/eberon_context.js

@@ -713,6 +713,11 @@ var ProcOrMethodDecl = Context.ProcDecl.extend({
                                    : Type.typeName(this.__boundType) + ".prototype." + this.__methodId.id() + " = function("
                                    : Type.typeName(this.__boundType) + ".prototype." + this.__methodId.id() + " = function("
             : Context.ProcDecl.prototype._prolog.call(this);
             : Context.ProcDecl.prototype._prolog.call(this);
     },
     },
+    _epilog: function(){
+        return this.__boundType && !this.__isConstructor
+            ? ";\n"
+            : Context.ProcDecl.prototype._epilog.call(this);
+    },
     _beginBody: function(){
     _beginBody: function(){
         Context.ProcDecl.prototype._beginBody.call(this);
         Context.ProcDecl.prototype._beginBody.call(this);
         if (this.__isConstructor)
         if (this.__isConstructor)

+ 7 - 7
test/expected/eberon/method.js

@@ -10,12 +10,12 @@ RTL$.extend(D, T);
 var dp = null;
 var dp = null;
 T.prototype.p = function(){
 T.prototype.p = function(){
 	this.i = 123;
 	this.i = 123;
-}
+};
 T.prototype.p2 = function(i/*INTEGER*/){
 T.prototype.p2 = function(i/*INTEGER*/){
 	return i;
 	return i;
-}
+};
 T.prototype.methodDefinedWithoutEndingIdent = function(){
 T.prototype.methodDefinedWithoutEndingIdent = function(){
-}
+};
 
 
 function acceptPointer(p/*PT*/){
 function acceptPointer(p/*PT*/){
 }
 }
@@ -28,20 +28,20 @@ function acceptConstReferenace(p/*T*/){
 T.prototype.useSelfAsVar = function(){
 T.prototype.useSelfAsVar = function(){
 	acceptReference(this);
 	acceptReference(this);
 	acceptConstReferenace(this);
 	acceptConstReferenace(this);
-}
+};
 T.prototype.useSelfAsPointer = function(){
 T.prototype.useSelfAsPointer = function(){
 	var pVar = null;
 	var pVar = null;
 	pVar = this;
 	pVar = this;
 	acceptPointer(this);
 	acceptPointer(this);
 	acceptReference(this);
 	acceptReference(this);
 	acceptConstReferenace(this);
 	acceptConstReferenace(this);
-}
+};
 D.prototype.p = function(){
 D.prototype.p = function(){
 	T.prototype.p.call(this);
 	T.prototype.p.call(this);
-}
+};
 D.prototype.p2 = function(i/*INTEGER*/){
 D.prototype.p2 = function(i/*INTEGER*/){
 	return T.prototype.p2.call(this, i);
 	return T.prototype.p2.call(this, i);
-}
+};
 dp = new D();
 dp = new D();
 dp.p();
 dp.p();
 dp.p();
 dp.p();

+ 2 - 2
test/expected/eberon/modules.js

@@ -3,7 +3,7 @@ var m1 = function (){
 function Base(){
 function Base(){
 }
 }
 Base.prototype.p = function(){
 Base.prototype.p = function(){
-}
+};
 return {
 return {
 	Base: Base
 	Base: Base
 }
 }
@@ -15,5 +15,5 @@ function T(){
 RTL$.extend(T, m1.Base);
 RTL$.extend(T, m1.Base);
 T.prototype.p = function(){
 T.prototype.p = function(){
 	m1.Base.prototype.p.call(this);
 	m1.Base.prototype.p.call(this);
-}
+};
 }(m1);
 }(m1);