GP-5459: For userop libraries, treat empty as empty, not unimpl

This commit is contained in:
Dan
2025-03-24 19:16:21 +00:00
parent 6b24b84bd8
commit 852db3a80a
2 changed files with 22 additions and 5 deletions

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,7 @@
package ghidra.pcode.struct.sub;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
@@ -25,8 +26,7 @@ import org.junit.Before;
import org.junit.Test;
import ghidra.app.plugin.processors.sleigh.SleighException;
import ghidra.pcode.exec.PcodeUseropLibrary;
import ghidra.pcode.exec.SleighPcodeUseropDefinition;
import ghidra.pcode.exec.*;
import ghidra.pcode.struct.StructuredSleigh;
import ghidra.program.model.lang.*;
import ghidra.program.model.pcode.Varnode;
@@ -238,4 +238,16 @@ public class StructuredSleighTest extends AbstractGhidraHeadlessIntegrationTest
// TODO: Test that the generated code compiles in a slaspec file.
// It's rejected for injects because "return" is not valid there.
}
@Test
public void testEmpty() throws Exception {
StructuredSleigh ss = new TestStructuredSleigh() {
@StructuredUserop
public void my_userop() {
}
};
SleighPcodeUseropDefinition<Object> myUserop = ss.generate().get("my_userop");
PcodeProgram program = myUserop.programFor(null, List.of(), PcodeUseropLibrary.nil());
assertTrue(program.getCode().isEmpty());
}
}