Skip to content

Commit 84676f7

Browse files
committed
refactoring - remove RuntimeDataProvider class
1 parent a755c35 commit 84676f7

17 files changed

+143
-43
lines changed

src/main/java/org/perlonjava/codegen/EmitLiteral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static void emitHashLiteral(EmitterVisitor emitterVisitor, HashLiteralNod
136136
mv.visitMethodInsn(Opcodes.INVOKESTATIC,
137137
"org/perlonjava/runtime/RuntimeHash",
138138
"createHashRef",
139-
"(Lorg/perlonjava/runtime/RuntimeDataProvider;)Lorg/perlonjava/runtime/RuntimeScalar;", false);
139+
"(Lorg/perlonjava/runtime/RuntimeBase;)Lorg/perlonjava/runtime/RuntimeScalar;", false);
140140

141141
emitterVisitor.ctx.logDebug("visit(HashLiteralNode) end");
142142
}

src/main/java/org/perlonjava/codegen/EmitOperator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void handleAtan2(EmitterVisitor emitterVisitor, OperatorNode node) {
182182
// Handles the 'die' built-in function, which throws an exception.
183183
static void handleDieBuiltin(EmitterVisitor emitterVisitor, OperatorNode node) {
184184
// Handle: die LIST
185-
// static RuntimeDataProvider die(RuntimeDataProvider value, int ctx)
185+
// static RuntimeBase die(RuntimeBase value, int ctx)
186186
emitterVisitor.ctx.logDebug("handleDieBuiltin " + node);
187187
// Accept the operand in LIST context.
188188
node.operand.accept(emitterVisitor.with(RuntimeContextType.LIST));
@@ -196,7 +196,7 @@ static void handleDieBuiltin(EmitterVisitor emitterVisitor, OperatorNode node) {
196196
// Handles the 'reverse' built-in function, which reverses a list.
197197
static void handleReverseBuiltin(EmitterVisitor emitterVisitor, OperatorNode node) {
198198
// Handle: reverse LIST
199-
// static RuntimeDataProvider reverse(RuntimeDataProvider value, int ctx)
199+
// static RuntimeBase reverse(RuntimeBase value, int ctx)
200200
emitterVisitor.ctx.logDebug("handleReverseBuiltin " + node);
201201
// Accept the operand in LIST context.
202202
node.operand.accept(emitterVisitor.with(RuntimeContextType.LIST));
@@ -322,7 +322,7 @@ static void handleRepeat(EmitterVisitor emitterVisitor, BinaryOperatorNode node)
322322
// Invoke the static method for the 'repeat' operator.
323323
emitterVisitor.ctx.mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/perlonjava/operators/Operator",
324324
"repeat",
325-
"(Lorg/perlonjava/runtime/RuntimeDataProvider;Lorg/perlonjava/runtime/RuntimeScalar;I)Lorg/perlonjava/runtime/RuntimeBase;", false);
325+
"(Lorg/perlonjava/runtime/RuntimeBase;Lorg/perlonjava/runtime/RuntimeScalar;I)Lorg/perlonjava/runtime/RuntimeBase;", false);
326326

327327
if (emitterVisitor.ctx.contextType == RuntimeContextType.SCALAR) {
328328
emitterVisitor.ctx.mv.visitTypeInsn(Opcodes.CHECKCAST, "org/perlonjava/runtime/RuntimeScalar");

src/main/java/org/perlonjava/codegen/EmitSubroutine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void handleApplyOperator(EmitterVisitor emitterVisitor, BinaryOperatorNod
154154
Opcodes.INVOKESTATIC,
155155
"org/perlonjava/runtime/RuntimeCode",
156156
"apply",
157-
"(Lorg/perlonjava/runtime/RuntimeScalar;Ljava/lang/String;Lorg/perlonjava/runtime/RuntimeDataProvider;I)Lorg/perlonjava/runtime/RuntimeList;",
157+
"(Lorg/perlonjava/runtime/RuntimeScalar;Ljava/lang/String;Lorg/perlonjava/runtime/RuntimeBase;I)Lorg/perlonjava/runtime/RuntimeList;",
158158
false); // Generate an .apply() call
159159
if (emitterVisitor.ctx.contextType == RuntimeContextType.SCALAR) {
160160
// Transform the value in the stack to RuntimeScalar

src/main/java/org/perlonjava/operators/Operator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static RuntimeScalar xor(RuntimeScalar left, RuntimeScalar right) {
2222
return getScalarBoolean(left.getBoolean() ^ right.getBoolean());
2323
}
2424

25-
public static RuntimeScalar join(RuntimeScalar runtimeScalar, RuntimeDataProvider list) {
25+
public static RuntimeScalar join(RuntimeScalar runtimeScalar, RuntimeBase list) {
2626
String delimiter = runtimeScalar.toString();
2727
// Join the list into a string
2828
StringBuilder sb = new StringBuilder();
@@ -689,15 +689,15 @@ public static RuntimeList splice(RuntimeArray runtimeArray, RuntimeList list) {
689689

690690
int offset;
691691
if (!list.isEmpty()) {
692-
RuntimeDataProvider value = list.elements.removeFirst();
692+
RuntimeBase value = list.elements.removeFirst();
693693
offset = value.scalar().getInt();
694694
} else {
695695
offset = 0;
696696
}
697697

698698
int length;
699699
if (!list.elements.isEmpty()) {
700-
RuntimeDataProvider value = list.elements.removeFirst();
700+
RuntimeBase value = list.elements.removeFirst();
701701
length = value.scalar().getInt();
702702
} else {
703703
length = size;
@@ -742,7 +742,7 @@ public static RuntimeList splice(RuntimeArray runtimeArray, RuntimeList list) {
742742
* @param value The list of files to be deleted.
743743
* @return A RuntimeScalar indicating the result of the unlink operation.
744744
*/
745-
public static RuntimeBase unlink(RuntimeDataProvider value, int ctx) {
745+
public static RuntimeBase unlink(RuntimeBase value, int ctx) {
746746

747747
boolean allDeleted = true;
748748
RuntimeList fileList = value.getList();
@@ -765,7 +765,7 @@ public static RuntimeBase unlink(RuntimeDataProvider value, int ctx) {
765765
return getScalarBoolean(allDeleted);
766766
}
767767

768-
public static RuntimeBase reverse(RuntimeDataProvider value, int ctx) {
768+
public static RuntimeBase reverse(RuntimeBase value, int ctx) {
769769
if (ctx == RuntimeContextType.SCALAR) {
770770
StringBuilder sb = new StringBuilder();
771771

@@ -801,7 +801,7 @@ public static RuntimeBase reverse(RuntimeDataProvider value, int ctx) {
801801
}
802802
}
803803

804-
public static RuntimeBase repeat(RuntimeDataProvider value, RuntimeScalar timesScalar, int ctx) {
804+
public static RuntimeBase repeat(RuntimeBase value, RuntimeScalar timesScalar, int ctx) {
805805
int times = timesScalar.getInt();
806806
if (ctx == RuntimeContextType.SCALAR || value instanceof RuntimeScalar) {
807807
StringBuilder sb = new StringBuilder();

src/main/java/org/perlonjava/operators/OperatorHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ public class OperatorHandler {
124124
put("select", "select", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeList;I)Lorg/perlonjava/runtime/RuntimeScalar;");
125125
put("caller", "caller", "org/perlonjava/runtime/RuntimeCode", "(Lorg/perlonjava/runtime/RuntimeList;I)Lorg/perlonjava/runtime/RuntimeList;");
126126
put("reset", "reset", "org/perlonjava/runtime/RuntimeScalar", "(Lorg/perlonjava/runtime/RuntimeList;I)Lorg/perlonjava/runtime/RuntimeList;");
127-
put("warn", "warn", "org/perlonjava/operators/WarnDie", "(Lorg/perlonjava/runtime/RuntimeDataProvider;Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeBase;");
128-
put("die", "die", "org/perlonjava/operators/WarnDie", "(Lorg/perlonjava/runtime/RuntimeDataProvider;Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeBase;");
127+
put("warn", "warn", "org/perlonjava/operators/WarnDie", "(Lorg/perlonjava/runtime/RuntimeBase;Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeBase;");
128+
put("die", "die", "org/perlonjava/operators/WarnDie", "(Lorg/perlonjava/runtime/RuntimeBase;Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeBase;");
129129
put("exit", "exit", "org/perlonjava/operators/WarnDie", "(Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeScalar;");
130-
put("reverse", "reverse", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeDataProvider;I)Lorg/perlonjava/runtime/RuntimeBase;");
130+
put("reverse", "reverse", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeBase;I)Lorg/perlonjava/runtime/RuntimeBase;");
131131
put("crypt", "crypt", "org/perlonjava/operators/Crypt", "(Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeScalar;");
132-
put("unlink", "unlink", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeDataProvider;I)Lorg/perlonjava/runtime/RuntimeBase;");
132+
put("unlink", "unlink", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeBase;I)Lorg/perlonjava/runtime/RuntimeBase;");
133133
put("stat", "stat", "org/perlonjava/operators/Stat", "(Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeList;");
134134
put("lstat", "lstat", "org/perlonjava/operators/Stat", "(Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeList;");
135135
put("vec", "vec", "org/perlonjava/operators/Vec", "(Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeScalar;");
@@ -141,7 +141,7 @@ public class OperatorHandler {
141141
put("read", "read", "org/perlonjava/operators/Readline", "(Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeScalar;");
142142

143143
put("x", "repeat", "org/perlonjava/runtime/RuntimeScalar", "(Lorg/perlonjava/runtime/RuntimeScalar;Lorg/perlonjava/runtime/RuntimeScalar;)Lorg/perlonjava/runtime/RuntimeScalar;");
144-
put("join", "join", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeScalar;Lorg/perlonjava/runtime/RuntimeDataProvider;)Lorg/perlonjava/runtime/RuntimeScalar;");
144+
put("join", "join", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeScalar;Lorg/perlonjava/runtime/RuntimeBase;)Lorg/perlonjava/runtime/RuntimeScalar;");
145145
put("split", "split", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeScalar;Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeList;");
146146

147147
put("truncate", "truncate", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeScalar;Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeScalar;");
@@ -164,8 +164,8 @@ public class OperatorHandler {
164164
put("pop", "pop", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;)Lorg/perlonjava/runtime/RuntimeScalar;");
165165
put("shift", "shift", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;)Lorg/perlonjava/runtime/RuntimeScalar;");
166166
put("splice", "splice", "org/perlonjava/operators/Operator", "(Lorg/perlonjava/runtime/RuntimeArray;Lorg/perlonjava/runtime/RuntimeList;)Lorg/perlonjava/runtime/RuntimeList;");
167-
put("push", "push", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;Lorg/perlonjava/runtime/RuntimeDataProvider;)Lorg/perlonjava/runtime/RuntimeScalar;");
168-
put("unshift", "unshift", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;Lorg/perlonjava/runtime/RuntimeDataProvider;)Lorg/perlonjava/runtime/RuntimeScalar;");
167+
put("push", "push", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;Lorg/perlonjava/runtime/RuntimeBase;)Lorg/perlonjava/runtime/RuntimeScalar;");
168+
put("unshift", "unshift", "org/perlonjava/runtime/RuntimeArray", "(Lorg/perlonjava/runtime/RuntimeArray;Lorg/perlonjava/runtime/RuntimeBase;)Lorg/perlonjava/runtime/RuntimeScalar;");
169169

170170
put("undef", "undef", "org/perlonjava/runtime/RuntimeScalar", "()Lorg/perlonjava/runtime/RuntimeScalar;");
171171
put("wantarray", "wantarray", "org/perlonjava/runtime/RuntimeScalar", "(I)Lorg/perlonjava/runtime/RuntimeScalar;");

src/main/java/org/perlonjava/operators/Readline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Readline {
1212
*
1313
* @param fileHandle The file handle.
1414
* @param ctx The context (SCALAR or LIST).
15-
* @return A RuntimeDataProvider with the line(s).
15+
* @return A RuntimeBase with the line(s).
1616
*/
1717
public static RuntimeBase readline(RuntimeScalar fileHandle, int ctx) {
1818
RuntimeIO fh = fileHandle.getRuntimeIO();

src/main/java/org/perlonjava/operators/ScalarGlobOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public ScalarGlobOperator(String pattern) {
6565
* @param id the unique identifier for this glob operator instance
6666
* @param patternArg the glob pattern as a RuntimeScalar
6767
* @param ctx the runtime context (scalar or list)
68-
* @return RuntimeDataProvider containing the results
68+
* @return RuntimeBase containing the results
6969
*/
7070
public static RuntimeBase evaluate(int id, RuntimeScalar patternArg, int ctx) {
7171
String pattern = patternArg.toString();

src/main/java/org/perlonjava/operators/SystemOperator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class SystemOperator {
2626
private static final Pattern SHELL_METACHARACTERS = Pattern.compile("[*?\\[\\]{}()<>|&;`'\"\\\\$\\s]");
2727

2828
/**
29-
* Executes a system command and returns the output as a RuntimeDataProvider.
29+
* Executes a system command and returns the output as a RuntimeBase.
3030
* This implements Perl's backtick operator (`command`).
3131
*
3232
* @param command The command to execute as a RuntimeScalar.
3333
* @param ctx The context type, determining the return type (list or scalar).
34-
* @return The output of the command as a RuntimeDataProvider.
34+
* @return The output of the command as a RuntimeBase.
3535
* @throws PerlCompilerException if an error occurs during command execution or stream handling.
3636
*/
3737
public static RuntimeBase systemCommand(RuntimeScalar command, int ctx) {
@@ -232,7 +232,7 @@ private static void closeQuietly(BufferedReader reader) {
232232
*
233233
* @param output The command output as a String.
234234
* @param ctx The context type, determining the return type (list or scalar).
235-
* @return The processed output as a RuntimeDataProvider.
235+
* @return The processed output as a RuntimeBase.
236236
*/
237237
private static RuntimeBase processOutput(String output, int ctx) {
238238
if (ctx == RuntimeContextType.LIST) {

src/main/java/org/perlonjava/operators/WarnDie.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class WarnDie {
1919
*
2020
* @param message The warning message to be issued.
2121
* @param where Additional context or location information to append to the message.
22-
* @return A RuntimeDataProvider representing the result of the warning operation.
22+
* @return A RuntimeBase representing the result of the warning operation.
2323
*/
24-
public static RuntimeBase warn(RuntimeDataProvider message, RuntimeScalar where) {
24+
public static RuntimeBase warn(RuntimeBase message, RuntimeScalar where) {
2525
String out = message.toString();
2626
if (out.isEmpty()) {
2727
RuntimeScalar err = getGlobalVariable("main::@");
@@ -68,10 +68,10 @@ public static RuntimeBase warn(RuntimeDataProvider message, RuntimeScalar where)
6868
*
6969
* @param value The error message to be issued.
7070
* @param message Additional context or location information to append to the message.
71-
* @return A RuntimeDataProvider representing the result of the die operation.
71+
* @return A RuntimeBase representing the result of the die operation.
7272
* @throws PerlCompilerException if no custom die handler is defined.
7373
*/
74-
public static RuntimeBase die(RuntimeDataProvider value, RuntimeScalar message) {
74+
public static RuntimeBase die(RuntimeBase value, RuntimeScalar message) {
7575
String out = value.toString();
7676
if (out.isEmpty()) {
7777
RuntimeScalar err = getGlobalVariable("main::@");

src/main/java/org/perlonjava/runtime/PerlRange.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* This class supports both integer and string ranges, providing
1212
* an iterator to traverse through the range.
1313
*/
14-
public class PerlRange extends RuntimeBase implements RuntimeDataProvider, Iterable<RuntimeScalar> {
14+
public class PerlRange extends RuntimeBase implements Iterable<RuntimeScalar> {
1515
private final RuntimeScalar start;
1616
private final RuntimeScalar end;
1717

@@ -76,10 +76,10 @@ public Iterator<RuntimeScalar> iterator() {
7676
/**
7777
* Converts the range to an undefined state.
7878
*
79-
* @return A RuntimeDataProvider representing the undefined state.
79+
* @return A RuntimeBase representing the undefined state.
8080
*/
8181
@Override
82-
public RuntimeDataProvider undefine() {
82+
public RuntimeBase undefine() {
8383
return toList().undefine();
8484
}
8585

0 commit comments

Comments
 (0)