-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3eb5c8
commit 20b9bf7
Showing
6 changed files
with
654 additions
and
362 deletions.
There are no files selected for viewing
301 changes: 0 additions & 301 deletions
301
core/src/main/java/de/mirkosertic/bytecoder/core/optimizer/GraphPatternMatcher.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
core/src/main/java/de/mirkosertic/bytecoder/core/patternmatcher/EvaluationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2024 Mirko Sertic | ||
* | ||
* 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. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.core.patternmatcher; | ||
|
||
import de.mirkosertic.bytecoder.core.ir.Node; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
class EvaluationContext { | ||
|
||
private final Node[] nodeIndex; | ||
private final Map<Node, Node[]> outgoingFlows; | ||
|
||
EvaluationContext(final Node rootNode, final int indexSize) { | ||
this.nodeIndex = new Node[indexSize]; | ||
this.nodeIndex[0] = rootNode; | ||
this.outgoingFlows = new HashMap<>(); | ||
} | ||
|
||
Node getRoot() { | ||
return nodeIndex[0]; | ||
} | ||
|
||
Node[] outgoingDataFlowsFor(final Node node) { | ||
return outgoingFlows.computeIfAbsent(node, Node::outgoingDataFlows); | ||
} | ||
|
||
boolean nodeKnownAt(final int index) { | ||
return nodeIndex[index] != null; | ||
} | ||
|
||
void registerNodeAt(final int index, final Node node) { | ||
nodeIndex[index] = node; | ||
} | ||
|
||
Node getNodeAt(final int index) { | ||
return nodeIndex[index]; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
core/src/main/java/de/mirkosertic/bytecoder/core/patternmatcher/Match.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 Mirko Sertic | ||
* | ||
* 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. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.core.patternmatcher; | ||
|
||
import de.mirkosertic.bytecoder.core.ir.Node; | ||
|
||
import java.util.Map; | ||
|
||
public class Match { | ||
|
||
private final Node root; | ||
private final Map<Node, Node> mappings; | ||
|
||
Match(final Node root, final Map<Node, Node> mappings) { | ||
this.root = root; | ||
this.mappings = mappings; | ||
} | ||
|
||
public Node root() { | ||
return root; | ||
} | ||
|
||
public Node mappingFor(final Node node) { | ||
return mappings.get(node); | ||
} | ||
} |
Oops, something went wrong.