I was emitting illegal IL for branching. The TI Basic relationsl expressions leave...
authorMichael Welch <michaelgwelch@gmail.com>
Thu, 28 Dec 2006 23:01:11 +0000 (23:01 +0000)
committerMichael Welch <michaelgwelch@gmail.com>
Thu, 28 Dec 2006 23:01:11 +0000 (23:01 +0000)
mbasic/SyntaxTree/For.cs
mbasic/SyntaxTree/If.cs

index 08786f1..ded8625 100644 (file)
@@ -81,12 +81,15 @@ namespace mbasic.SyntaxTree
 
             gen.MarkLabel(condition);
             comparison.Emit(gen);
-            gen.Emit(OpCodes.Brtrue, start);
+            gen.Emit(OpCodes.Ldc_R8, 0.0);
+            gen.Emit(OpCodes.Ceq);
+            gen.Emit(OpCodes.Brfalse, start);
 
         }
 
         public override void RecordLabels(ILGenerator gen)
         {
+            base.RecordLabels(gen);
             init.RecordLabels(gen);
             update.RecordLabels(gen);
             stmt.RecordLabels(gen);
index 2a7c299..4e5d9ae 100644 (file)
@@ -61,7 +61,8 @@ namespace mbasic.SyntaxTree
             MarkSequencePoint(gen);
             Label falseCase = gen.DefineLabel();
             conditional.Emit(gen);
-            gen.Emit(OpCodes.Brfalse_S, falseCase);
+            gen.Emit(OpCodes.Ldc_R8, 0.0);
+            gen.Emit(OpCodes.Beq_S, falseCase);
             jmp.Emit(gen, true);
             gen.MarkLabel(falseCase);
             if (elseJmp != null) elseJmp.Emit(gen, true);