Browse Source

Check for inlineJS inside block and fail.

Herby Vojčík 6 years ago
parent
commit
c20a5c6617
2 changed files with 50 additions and 0 deletions
  1. 39 0
      src/Compiler-Semantic.js
  2. 11 0
      src/Compiler-Semantic.st

+ 39 - 0
src/Compiler-Semantic.js

@@ -2319,6 +2319,42 @@ messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "blockIndex:",
 }),
 $globals.SemanticAnalyzer);
 
+$core.addMethod(
+$core.method({
+selector: "visitBlockSequenceNode:",
+protocol: "visiting",
+fn: function (aNode){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($recv(aNode)._dagChildren())._anySatisfy_("isJSStatementNode");
+if($core.assert($1)){
+$recv($globals.JsStatementDisplacedError)._signal();
+}
+(
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = true,
+//>>excludeEnd("ctx");
+($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitBlockSequenceNode_.apply($self, [aNode]));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = false;
+//>>excludeEnd("ctx");;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aNode"],
+source: "visitBlockSequenceNode: aNode\x0a\x09(aNode dagChildren anySatisfy: #isJSStatementNode)\x0a\x09\x09ifTrue: [ JsStatementDisplacedError signal ].\x0a\x0a\x09super visitBlockSequenceNode: aNode\x0a\x09",
+referencedClasses: ["JsStatementDisplacedError"],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:", "anySatisfy:", "dagChildren", "signal", "visitBlockSequenceNode:"]
+}),
+$globals.SemanticAnalyzer);
+
 $core.addMethod(
 $core.method({
 selector: "visitCascadeNode:",
@@ -2702,6 +2738,9 @@ $globals.InvalidAssignmentError);
 
 
 
+$core.addClass("JsStatementDisplacedError", $globals.SemanticError, [], "Compiler-Semantic");
+
+
 $core.addClass("ShadowingVariableError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";

+ 11 - 0
src/Compiler-Semantic.st

@@ -564,6 +564,13 @@ visitBlockNode: aNode
 	self popScope
 !
 
+visitBlockSequenceNode: aNode
+	(aNode dagChildren anySatisfy: #isJSStatementNode)
+		ifTrue: [ JsStatementDisplacedError signal ].
+
+	super visitBlockSequenceNode: aNode
+!
+
 visitCascadeNode: aNode
 	aNode receiver: aNode dagChildren first receiver.
 	super visitCascadeNode: aNode
@@ -673,6 +680,10 @@ variableName: aString
 	variableName := aString
 ! !
 
+SemanticError subclass: #JsStatementDisplacedError
+	instanceVariableNames: ''
+	package: 'Compiler-Semantic'!
+
 SemanticError subclass: #ShadowingVariableError
 	instanceVariableNames: 'variableName'
 	package: 'Compiler-Semantic'!