/*******************************************************************************
* Copyright (c) 2011 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package dtool.ast.statements;
import melnorme.lang.tooling.ast.CommonASTNode;
import melnorme.lang.tooling.ast.IASTVisitor;
import melnorme.lang.tooling.ast.util.ASTCodePrinter;
import melnorme.lang.tooling.ast_actual.ASTNodeTypes;
import dtool.ast.expressions.Expression;
import dtool.ast.expressions.MissingParenthesesExpression;
public class StatementSynchronized extends Statement {
public final Expression exp;
public final IStatement body;
public StatementSynchronized(Expression exp, IStatement body) {
this.exp = parentize(exp);
this.body = parentize(body);
}
@Override
public ASTNodeTypes getNodeType() {
return ASTNodeTypes.STATEMENT_SYNCHRONIZED;
}
@Override
public void visitChildren(IASTVisitor visitor) {
acceptVisitor(visitor, exp);
acceptVisitor(visitor, body);
}
@Override
protected CommonASTNode doCloneTree() {
return new StatementSynchronized(clone(exp), clone(body));
}
@Override
public void toStringAsCode(ASTCodePrinter cp) {
cp.append("synchronized ");
MissingParenthesesExpression.appendParenthesesExp(cp, exp);
cp.append(body);
}
}