Skip to content

Commit

Permalink
rename SynchronizedChange to AbstractSynchronized
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyiteng committed Oct 22, 2019
1 parent 8499211 commit 987c5cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import java.util.List;

public abstract class SynchronizedChange extends Stmt_c {
public abstract class AbstractSynchronized extends Stmt_c {
protected Expr expr;

public SynchronizedChange(Position pos, Expr expr, Ext ext) {
public AbstractSynchronized(Position pos, Expr expr, Ext ext) {
super(pos, ext);
this.expr = expr;
}
Expand All @@ -32,14 +32,14 @@ public Expr expr() {
return expr;
}

protected <N extends SynchronizedChange> N expr(N n, Expr expr) {
protected <N extends AbstractSynchronized> N expr(N n, Expr expr) {
if (n.expr == expr) return n;
n = copyIfNeeded(n);
n.expr = expr;
return n;
}

protected <N extends SynchronizedChange> N reconstruct(N n, Expr expr) {
protected <N extends AbstractSynchronized> N reconstruct(N n, Expr expr) {
return expr(n, expr);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/jlang/ast/SynchronizedEnter_c.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import polyglot.util.Position;
import polyglot.visit.PrettyPrinter;

public class SynchronizedEnter_c extends SynchronizedChange implements SynchronizedEnter {
public class SynchronizedEnter_c extends AbstractSynchronized implements SynchronizedEnter {

SynchronizedEnter_c(Position pos, Expr expr, Ext ext) {
super(pos, expr, ext);
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/jlang/ast/SynchronizedExit_c.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import polyglot.util.Position;
import polyglot.visit.PrettyPrinter;

public class SynchronizedExit_c extends SynchronizedChange implements SynchronizedExit {
public class SynchronizedExit_c extends AbstractSynchronized implements SynchronizedExit {

SynchronizedExit_c(Position pos, Expr expr, Ext ext) {
super(pos, expr, ext);
Expand Down
7 changes: 4 additions & 3 deletions compiler/src/jlang/visit/DesugarSynchronized.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ protected Node leaveDesugar(Node n) throws SemanticException {
return desugarSynchronizedNode((Synchronized) n);
} else if (n instanceof MethodDecl) {
MethodDecl node = (MethodDecl) n;
if (node.flags().isSynchronized()) {
if (node.flags().isSynchronized() && node.body() != null) {
// TODO: how to handle public synchronized native void foo()
// Remove && node.body() != null after figure out how to handle it
Block body = node.body();
Expr synchronizedObj;
if (node.flags().isStatic()) {
Expand Down Expand Up @@ -64,14 +66,13 @@ protected Node leaveDesugar(Node n) throws SemanticException {
*/
private Block desugarSynchronizedNode(Synchronized node) {
Position pos = node.position();
// TempSSA or TempVar? Create unique name for each use?

LocalDecl declObj = tnf.TempSSA("syncObj", node.expr());
Local obj = tnf.Local(pos, declObj);

SynchronizedEnter syncEnter = nf.SynchronizedEnter(pos, copy(obj));
SynchronizedExit syncExit = nf.SynchronizedExit(pos, copy(obj));

// Should we copy the node?
Block tryBlock = nf.Block(pos, syncEnter, node.body());
Block finallyBlock = nf.Block(pos, syncExit);

Expand Down

0 comments on commit 987c5cd

Please sign in to comment.