Add in_area function. (Amend)

This commit is contained in:
2022-11-06 14:20:28 +08:00
parent b4fa5849ae
commit f33560daba
2 changed files with 16 additions and 5 deletions

View File

@@ -20,6 +20,13 @@ namespace Cryville.Common.Pdt {
Length = len;
}
/// <summary>
/// Copies the memory in the span to another span.
/// </summary>
/// <param name="dest">The destination span.</param>
public void CopyTo(PdtVariableMemory dest) {
CopyTo(dest._ptr, 0, Length);
}
/// <summary>
/// Copies the memory in the span to a buffer.
/// </summary>
/// <param name="dest">The destination buffer.</param>

View File

@@ -388,12 +388,16 @@ namespace Cryville.Crtr {
public func_in_area() : base(1) { }
protected override unsafe void Execute() {
var arg = GetOperand(0);
if (arg.Type == PdtInternalType.Number && arg.AsNumber() >= 0) {
GetReturnFrame(PdtInternalType.Null, 0);
return;
if (arg.Type == PdtInternalType.Error) {
throw new InvalidOperationException("Error");
}
else if (arg.Type == PdtInternalType.Number && arg.AsNumber() >= 0) {
GetReturnFrame(PdtInternalType.Null, 0);
}
else {
var ret = GetReturnFrame(arg.Type, arg.Length);
arg.CopyTo(ret);
}
var ret = GetReturnFrame(arg.Type, arg.Length);
arg.CopyTo(ret);
}
}
unsafe static class oputil {