Skip to content

Commit

Permalink
[GR-12251] Clean up deprecated methods in TRegex after adding Python …
Browse files Browse the repository at this point in the history
…flavor support.

PullRequest: graal/2379
  • Loading branch information
jirkamarsik committed Oct 25, 2018
2 parents b9dd7b0 + 7c90e6d commit 67f947b
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static RegexCompiler importRegexCompiler(TruffleObject regexCompiler) {
@Override
public TruffleObject compile(RegexSource source) throws RegexSyntaxException, UnsupportedRegexException {
try {
return (TruffleObject) ForeignAccess.sendExecute(executeNode, foreignCompiler, source.getPattern(), source.getGeneralFlags());
return (TruffleObject) ForeignAccess.sendExecute(executeNode, foreignCompiler, source.getPattern(), source.getFlags());
} catch (InteropException ex) {
throw ex.raise();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public RegexSource getSource() {
@Override
public SourceSection getSourceSection() {
if (sourceSection == null) {
String patternSrc = "/" + source.getPattern() + "/" + source.getGeneralFlags();
String patternSrc = "/" + source.getPattern() + "/" + source.getFlags();
Source src = Source.newBuilder(RegexLanguage.ID, patternSrc, source.getPattern()).mimeType("application/js-regex").build();
sourceSection = src.createSection(0, patternSrc.length());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public RegexObject compile(RegexSource regexSource) throws RegexSyntaxException,
flavorProcessor.validate();
regexObject = new RegexObject(compiler, regexSource, flavorProcessor.getFlags(), flavorProcessor.isUnicodePattern(), flavorProcessor.getNamedCaptureGroups());
} else {
RegexFlags flags = RegexFlags.parseFlags(regexSource.getGeneralFlags());
RegexFlags flags = RegexFlags.parseFlags(regexSource.getFlags());
RegexParser regexParser = new RegexParser(regexSource, options);
regexParser.validate();
regexObject = new RegexObject(compiler, regexSource, flags, regexParser.getFlags().isUnicode(), regexParser.getNamedCaptureGroups());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ public String getFlags() {
return flags;
}

/**
* Deprecated.
* <p>
* TODO: Remove this once it is no longer used by Graal.js.
*/
public String getGeneralFlags() {
return getFlags();
}

public Source getSource() {
if (source == null) {
String text = toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String getMessage() {
sb.append(" /");
sb.append(regexSrc.getPattern());
sb.append("/");
sb.append(regexSrc.getGeneralFlags());
sb.append(regexSrc.getFlags());
}
if (reason != null) {
sb.append(": ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class RegexUnifier {

public RegexUnifier(RegexSource source) {
this.source = source;
this.lexer = new RegexLexer(source, RegexFlags.parseFlags(source.getGeneralFlags()), RegexOptions.DEFAULT);
this.lexer = new RegexLexer(source, RegexFlags.parseFlags(source.getFlags()), RegexOptions.DEFAULT);
this.dump = new StringBuilder(source.getPattern().length());
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public String getUnifiedPattern() throws RegexSyntaxException {
}
}
dump.append("/");
dump.append(source.getGeneralFlags());
dump.append(source.getFlags());
return dump.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void phaseEnd(String phase) {
private void logAutomatonSizes(CompiledRegex result) {
logSizes(Json.obj(
Json.prop("pattern", source.getPattern()),
Json.prop("flags", source.getGeneralFlags()),
Json.prop("flags", source.getFlags()),
Json.prop("props", ast == null ? new RegexProperties() : ast.getProperties()),
Json.prop("astNodes", ast == null ? 0 : ast.getNumberOfNodes()),
Json.prop("nfaStates", nfa == null ? 0 : nfa.getStates().length),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,6 @@ private boolean isEscapeCharClass(char c) {
}

private RegexSyntaxException syntaxError(String msg) {
return new RegexSyntaxException(pattern, source.getGeneralFlags(), msg);
return new RegexSyntaxException(pattern, source.getFlags(), msg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public final class RegexParser {
@TruffleBoundary
public RegexParser(RegexSource source, RegexOptions options) throws RegexSyntaxException {
this.source = source;
this.flags = RegexFlags.parseFlags(source.getGeneralFlags());
this.flags = RegexFlags.parseFlags(source.getFlags());
this.lexer = new RegexLexer(source, flags, options);
this.ast = new RegexAST(source, flags, options);
this.properties = ast.getProperties();
Expand Down Expand Up @@ -635,7 +635,7 @@ private boolean tryMergeSingleCharClassAlternations() {
}

private RegexSyntaxException syntaxError(String msg) {
return new RegexSyntaxException(source.getPattern(), source.getGeneralFlags(), msg);
return new RegexSyntaxException(source.getPattern(), source.getFlags(), msg);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private static final class Group {
@TruffleBoundary
public PythonFlavorProcessor(RegexSource source, PythonREMode mode) {
this.inPattern = source.getPattern();
this.inFlags = source.getGeneralFlags();
this.inFlags = source.getFlags();
this.mode = mode;
this.position = 0;
this.outPattern = new StringBuilder(inPattern.length());
Expand Down
4 changes: 2 additions & 2 deletions vm/mx.vm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"name": "graal-nodejs",
"subdir": True,
"dynamic": True,
"version": "e03edeb4898836b20148f074c9143087c25cd431",
"version": "6d260d9fdb3db18a0e4b1035d5485fde13c95702",
"urls" : [
{"url" : "https://github.com/graalvm/graaljs.git", "kind" : "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand All @@ -29,7 +29,7 @@
"name": "graal-js",
"subdir": True,
"dynamic": True,
"version": "e03edeb4898836b20148f074c9143087c25cd431",
"version": "6d260d9fdb3db18a0e4b1035d5485fde13c95702",
"urls": [
{"url": "https://github.com/graalvm/graaljs.git", "kind" : "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand Down

0 comments on commit 67f947b

Please sign in to comment.