Pārlūkot izejas kodu

Fixed volatile locals in nested try stmts. Fixes #312.

woollybah 7 gadi atpakaļ
vecāks
revīzija
c9999216c8
3 mainītis faili ar 14 papildinājumiem un 7 dzēšanām
  1. 1 1
      decl.bmx
  2. 8 4
      expr.bmx
  3. 5 2
      stmt.bmx

+ 1 - 1
decl.bmx

@@ -600,7 +600,7 @@ Type TLocalDecl Extends TVarDecl
 
 	Field done:Int
 	Field volatile:Int = False
-	Field declaredInTry:Int
+	Field declaredInTry:TTryStmtDecl
 
 	Method Create:TLocalDecl( ident$,ty:TType,init:TExpr,attrs:Int=0, generated:Int = False, volatile:Int = False )
 		Self.ident=ident

+ 8 - 4
expr.bmx

@@ -167,8 +167,9 @@ Type TExpr
 					' passing a non volatile local as Var from within a Try block?					
 					If TVarExpr(args[i]) Then
 						Local ldecl:TLocalDecl = TLocalDecl(TVarExpr(args[i]).decl)
-						If ldecl Then
-							If Not ldecl.volatile And Not ldecl.declaredInTry And _env.FindTry() Then
+						If ldecl And Not ldecl.volatile Then
+							Local tryStmtDecl:TTryStmtDecl = _env.FindTry()
+							If tryStmtDecl And (Not ldecl.declaredInTry Or tryStmtDecl <> ldecl.declaredInTry) Then
 								ldecl.volatile = True
 							End If
 						End If
@@ -2567,8 +2568,11 @@ Type TIdentExpr Extends TExpr
 
 				Local ldecl:TLocalDecl = TLocalDecl( vdecl )
 
-				If Not ldecl.volatile And Not ldecl.declaredInTry And scope.FindTry() Then
-					ldecl.volatile = True
+				If Not ldecl.volatile Then
+					Local tryStmtDecl:TTryStmtDecl = scope.FindTry()
+					If tryStmtDecl And (Not ldecl.declaredInTry Or tryStmtDecl <> ldecl.declaredInTry) Then
+						ldecl.volatile = True
+					End If
 				End If
 
 			Else If TConstDecl( vdecl )

+ 5 - 2
stmt.bmx

@@ -77,8 +77,11 @@ Type TDeclStmt Extends TStmt
 	End Method
 	
 	Method OnSemant()
-		If TLocalDecl(decl) And _env.FindTry() Then
-			TLocalDecl(decl).declaredInTry = True
+		If TLocalDecl(decl) Then
+			Local tryStmtDecl:TTryStmtDecl = _env.FindTry()
+			If tryStmtDecl Then
+				TLocalDecl(decl).declaredInTry = tryStmtDecl
+			End If
 		End If
 		
 		decl.Semant