-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* catch arithmetic traps * memory and table section guards
- Loading branch information
1 parent
abff527
commit 34176a6
Showing
46 changed files
with
305 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
chasm/src/commonTest/kotlin/io/github/charlietap/chasm/script/action/InvokeActionRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
package io.github.charlietap.chasm.script.action | ||
|
||
import io.github.charlietap.chasm.embedding.invoke | ||
import io.github.charlietap.chasm.expect | ||
import io.github.charlietap.chasm.fold | ||
import io.github.charlietap.chasm.script.ScriptContext | ||
import io.github.charlietap.chasm.script.action.ActionResult.Success | ||
import io.github.charlietap.chasm.script.value.ValueMapper | ||
import io.github.charlietap.sweet.lib.action.InvokeAction | ||
import io.github.charlietap.sweet.lib.command.Command | ||
|
||
typealias InvokeActionRunner = (ScriptContext, InvokeAction) -> ActionResult | ||
typealias InvokeActionRunner = (ScriptContext, Command, InvokeAction) -> ActionResult | ||
|
||
fun InvokeActionRunner( | ||
context: ScriptContext, | ||
command: Command, | ||
action: InvokeAction, | ||
) = InvokeActionRunner( | ||
context = context, | ||
command = command, | ||
action = action, | ||
valueMapper = ::ValueMapper, | ||
) | ||
|
||
private fun InvokeActionRunner( | ||
context: ScriptContext, | ||
command: Command, | ||
action: InvokeAction, | ||
valueMapper: ValueMapper, | ||
): ActionResult { | ||
return invoke( | ||
val result = invoke( | ||
context.store, | ||
context.instances[action.moduleName]!!, | ||
action.field, | ||
action.args.mapNotNull(valueMapper), | ||
).expect("Invoke failed").let(::Success) | ||
) | ||
|
||
return result.fold({ results -> | ||
ActionResult.Success(results) | ||
}) { error -> | ||
ActionResult.Failure(command, "invoke action returned an error", error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...o/github/charlietap/chasm/executor/instantiator/classification/ExternalValueClassifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package io.github.charlietap.chasm.executor.instantiator.classification | ||
|
||
import com.github.michaelbull.result.Result | ||
import io.github.charlietap.chasm.executor.runtime.error.ModuleRuntimeError | ||
import io.github.charlietap.chasm.executor.runtime.error.ModuleTrapError | ||
import io.github.charlietap.chasm.executor.runtime.instance.ExternalValue | ||
import io.github.charlietap.chasm.executor.runtime.store.Store | ||
|
||
internal typealias ExternalValueClassifier = (Store, ExternalValue) -> Result<ClassifiedExternalValue, ModuleRuntimeError> | ||
internal typealias ExternalValueClassifier = (Store, ExternalValue) -> Result<ClassifiedExternalValue, ModuleTrapError> |
Oops, something went wrong.