1515 */
1616public class StrCpyInstruction extends AssembleExpression {
1717 public static final String name = "StrCpy" ;
18+ protected final String instructionName ;
1819 private final Expression string ;
1920 private final Expression maxLen ;
2021 private final Expression startOffset ;
@@ -25,14 +26,25 @@ public class StrCpyInstruction extends AssembleExpression {
2526 * @param returns the number of values to return
2627 */
2728 public StrCpyInstruction (int returns ) {
29+ this (returns , name );
30+ }
31+
32+ /**
33+ * Class constructor for subclasses with different instruction names.
34+ *
35+ * @param returns the number of values to return
36+ * @param instructionName the name of the instruction (e.g., "StrCpy" or "UnsafeStrCpy")
37+ */
38+ protected StrCpyInstruction (int returns , String instructionName ) {
39+ this .instructionName = instructionName ;
2840 if (PageExInfo .in ())
2941 throw new NslContextException (
30- EnumSet .of (NslContext .Section , NslContext .Function , NslContext .Global ), name );
31- if (returns != 11 ) throw new NslReturnValueException (name , 1 );
42+ EnumSet .of (NslContext .Section , NslContext .Function , NslContext .Global ), instructionName );
43+ if (returns != 1 ) throw new NslReturnValueException (instructionName , 1 );
3244
3345 ArrayList <Expression > paramsList = Expression .matchList ();
3446 int paramsCount = paramsList .size ();
35- if (paramsCount < 1 || paramsCount > 3 ) throw new NslArgumentException (name , 1 , 3 );
47+ if (paramsCount < 1 || paramsCount > 3 ) throw new NslArgumentException (instructionName , 1 , 3 );
3648
3749 this .string = paramsList .get (0 );
3850
@@ -73,14 +85,22 @@ public void assemble(Register var) throws IOException {
7385 if (this .startOffset != null ) {
7486 Expression varOrStartOffset = AssembleExpression .getRegisterOrExpression (this .startOffset );
7587 ScriptParser .writeLine (
76- name + " " + var + " " + varOrString + " " + varOrMaxLen + " " + varOrStartOffset );
88+ instructionName
89+ + " "
90+ + var
91+ + " "
92+ + varOrString
93+ + " "
94+ + varOrMaxLen
95+ + " "
96+ + varOrStartOffset );
7797 varOrStartOffset .setInUse (false );
7898 } else {
79- ScriptParser .writeLine (name + " " + var + " " + varOrString + " " + varOrMaxLen );
99+ ScriptParser .writeLine (instructionName + " " + var + " " + varOrString + " " + varOrMaxLen );
80100 }
81101 varOrMaxLen .setInUse (false );
82102 } else {
83- ScriptParser .writeLine (name + " " + var + " " + varOrString );
103+ ScriptParser .writeLine (instructionName + " " + var + " " + varOrString );
84104 }
85105 varOrString .setInUse (false );
86106 }
0 commit comments