Skip to content

Commit 8279a78

Browse files
andrykonchineregon
authored andcommitted
Adopt partially renaming YARP to Prism
1 parent d7988f8 commit 8279a78

File tree

8 files changed

+36
-570
lines changed

8 files changed

+36
-570
lines changed

doc/contributor/prism.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Prism
2+
3+
## Update Prism
4+
5+
* Clone `prism` as a sibling of `truffleruby-ws`.
6+
* Run `tool/import-prism.sh` in the truffleruby repo.
7+
* Commit the result with message `Import ruby/prism@COMMIT`
8+
9+
## Print Detailed Prism AST
10+
11+
```bash
12+
cd prism
13+
chruby 3.2.
14+
bundle exec rake
15+
bundle exec ruby -Ilib -rprism -e 'pp Prism.parse("1&.itself")'
16+
```

doc/contributor/yarp.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main/c/yarp/src/serialize.c

Lines changed: 0 additions & 534 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
#include "yarp.h"
2-
#include "org_yarp_Parser.h"
1+
#include "prism.h"
2+
#include "org_prism_Parser.h"
33

4-
JNIEXPORT jbyteArray JNICALL Java_org_yarp_Parser_parseAndSerialize(JNIEnv *env, jclass clazz, jbyteArray source) {
4+
JNIEXPORT jbyteArray JNICALL Java_org_prism_Parser_parseAndSerialize(JNIEnv *env, jclass clazz, jbyteArray source) {
55
jsize size = (*env)->GetArrayLength(env, source);
66
// Null-terminate for safety, as parsers are prone to read further than the end
77
jbyte* bytes = malloc(size + 4);
88
(*env)->GetByteArrayRegion(env, source, 0, size, bytes);
99
memset(bytes + size, 0, 4);
1010

11-
yp_buffer_t buffer;
12-
yp_buffer_init(&buffer);
11+
pm_buffer_t buffer;
12+
pm_buffer_init(&buffer);
1313

14-
yp_parse_serialize((uint8_t*) bytes, size, &buffer, NULL);
14+
pm_parse_serialize((uint8_t*) bytes, size, &buffer, NULL);
1515

1616
free(bytes);
1717

1818
jbyteArray serialized = (*env)->NewByteArray(env, buffer.length);
1919
(*env)->SetByteArrayRegion(env, serialized, 0, buffer.length, (jbyte*) buffer.value);
2020

21-
yp_buffer_free(&buffer);
21+
pm_buffer_free(&buffer);
2222

2323
return serialized;
2424
}

src/main/java/org/truffleruby/debug/TruffleDebugNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@
116116
import org.truffleruby.parser.parser.ParserConfiguration;
117117
import org.truffleruby.parser.scope.StaticScope;
118118
import org.truffleruby.platform.Platform;
119-
import org.yarp.Loader;
120-
import org.yarp.Parser;
119+
import org.prism.Loader;
120+
import org.prism.Parser;
121121

122122
@CoreModule("Truffle::Debug")
123123
public abstract class TruffleDebugNodes {

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
import org.truffleruby.language.objects.WriteInstanceVariableNodeGen;
118118
import org.truffleruby.language.objects.classvariables.ReadClassVariableNode;
119119
import org.truffleruby.language.objects.classvariables.WriteClassVariableNode;
120-
import org.yarp.AbstractNodeVisitor;
121-
import org.yarp.Nodes;
120+
import org.prism.AbstractNodeVisitor;
121+
import org.prism.Nodes;
122122

123123
import java.util.ArrayDeque;
124124
import java.util.ArrayList;

src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484
import org.truffleruby.parser.scope.StaticScope;
8585
import org.truffleruby.platform.Platform;
8686
import org.truffleruby.shared.Metrics;
87-
import org.yarp.Loader;
88-
import org.yarp.Nodes;
89-
import org.yarp.ParseResult;
90-
import org.yarp.Parser;
87+
import org.prism.Loader;
88+
import org.prism.Nodes;
89+
import org.prism.ParseResult;
90+
import org.prism.Parser;
9191

9292
import java.util.ArrayList;
9393
import java.util.Arrays;
@@ -174,7 +174,7 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
174174

175175
// Parse to the YARP AST
176176

177-
final org.yarp.Nodes.Node node;
177+
final org.prism.Nodes.Node node;
178178

179179
final RubyDeferredWarnings rubyWarnings = new RubyDeferredWarnings();
180180

@@ -395,7 +395,7 @@ private String getMethodName(ParserContext parserContext, MaterializedFrame pare
395395
}
396396
}
397397

398-
public static org.yarp.Nodes.Node parseToYARPAST(RubyContext context, RubyLanguage language, RubySource rubySource,
398+
public static org.prism.Nodes.Node parseToYARPAST(RubyContext context, RubyLanguage language, RubySource rubySource,
399399
StaticScope blockScope, ParserConfiguration configuration, RubyDeferredWarnings rubyWarnings) {
400400
// LexerSource lexerSource = new LexerSource(rubySource);
401401
// We only need to pass in current scope if we are evaluating as a block (which
@@ -409,7 +409,7 @@ public static org.yarp.Nodes.Node parseToYARPAST(RubyContext context, RubyLangua
409409

410410
// YARP begin
411411
byte[] sourceBytes = rubySource.getBytes();
412-
org.yarp.Parser.loadLibrary(language.getRubyHome() + "/lib/libyarp" + Platform.LIB_SUFFIX);
412+
org.prism.Parser.loadLibrary(language.getRubyHome() + "/lib/libyarp" + Platform.LIB_SUFFIX);
413413
byte[] serializedBytes = Parser.parseAndSerialize(sourceBytes);
414414

415415
var yarpSource = createYARPSource(sourceBytes, rubySource);

tool/import-yarp.sh renamed to tool/import-prism.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
set -x
44
set -e
55

6-
YARP=../../yarp
6+
YARP=../../prism
77

8-
export YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS=1
8+
export PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS=1
99

1010
# Create generated files
1111
pushd $YARP

0 commit comments

Comments
 (0)