fix C# fork() error

This commit is contained in:
2021-07-20 16:41:08 -06:00
parent bb6cd08b32
commit 4b9f129d00
3 changed files with 5 additions and 5 deletions

View File

@@ -1,2 +1,2 @@
#! /bin/bash
mono bin/cs/test/bin/TestMain.exe || echo "C# tests failed"
mono bin/cs/test/bin/TestMain.exe

View File

@@ -212,7 +212,8 @@ class EmbeddedScript {
var fork = new kiss.cloner.Cloner().clone(this);
fork.instructions[instructionPointer] = command;
if (fork.breakPoints == null) {
throw 'cloning failed';
// This field is so much trouble to clone in C# because of its type
fork.breakPoints = [for (point => condition in this.breakPoints) point => condition];
}
// trace('running a fork from ' + Std.string(instructionPointer + 1));
fork.run();

View File

@@ -100,13 +100,12 @@ class Cloner {
var classValue = Type.getClass(inValue);
var outValue:T = Type.createEmptyInstance(classValue);
var fields:Array<String> = Type.getInstanceFields(classValue);
for (i in 0...fields.length) {
var field = fields[i];
for (field in fields) {
var property = Reflect.getProperty(inValue, field);
try {
Reflect.setField(outValue, field, _clone(property));
} catch (s) {
// There will be errors on C++ when trying to assign to a member function.
// There will be errors on C++ and C# when trying to assign to a member function.
// They're not important, because the function will already be on the clone.
}
}