/******************************************************************************* * Copyright (c) 2009-2015 CWI * 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: * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl * * Paul Klint - Paul.Klint@cwi.nl - CWI * * Mark Hills - Mark.Hills@cwi.nl (CWI) * * Arnold Lankamp - Arnold.Lankamp@cwi.nl * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI *******************************************************************************/ package org.rascalmpl.ast; import org.rascalmpl.value.IConstructor; import org.rascalmpl.value.ISourceLocation; public abstract class Case extends AbstractAST { public Case(ISourceLocation src, IConstructor node) { super(src /* we forget node on purpose */); } public boolean hasPatternWithAction() { return false; } public org.rascalmpl.ast.PatternWithAction getPatternWithAction() { throw new UnsupportedOperationException(); } public boolean hasStatement() { return false; } public org.rascalmpl.ast.Statement getStatement() { throw new UnsupportedOperationException(); } public boolean isDefault() { return false; } static public class Default extends Case { // Production: sig("Default",[arg("org.rascalmpl.ast.Statement","statement")],breakable=false) private final org.rascalmpl.ast.Statement statement; public Default(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) { super(src, node); this.statement = statement; } @Override public boolean isDefault() { return true; } @Override public <T> T accept(IASTVisitor<T> visitor) { return visitor.visitCaseDefault(this); } @Override protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) { if (getLocation().getBeginLine() == $line) { $result.add(this); } ISourceLocation $l; $l = statement.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { statement.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } } @Override public boolean equals(Object o) { if (!(o instanceof Default)) { return false; } Default tmp = (Default) o; return true && tmp.statement.equals(this.statement) ; } @Override public int hashCode() { return 307 + 881 * statement.hashCode() ; } @Override public org.rascalmpl.ast.Statement getStatement() { return this.statement; } @Override public boolean hasStatement() { return true; } @Override public Object clone() { return newInstance(getClass(), src, (IConstructor) null , clone(statement)); } } public boolean isPatternWithAction() { return false; } static public class PatternWithAction extends Case { // Production: sig("PatternWithAction",[arg("org.rascalmpl.ast.PatternWithAction","patternWithAction")],breakable=false) private final org.rascalmpl.ast.PatternWithAction patternWithAction; public PatternWithAction(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PatternWithAction patternWithAction) { super(src, node); this.patternWithAction = patternWithAction; } @Override public boolean isPatternWithAction() { return true; } @Override public <T> T accept(IASTVisitor<T> visitor) { return visitor.visitCasePatternWithAction(this); } @Override protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) { if (getLocation().getBeginLine() == $line) { $result.add(this); } ISourceLocation $l; $l = patternWithAction.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { patternWithAction.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } } @Override public boolean equals(Object o) { if (!(o instanceof PatternWithAction)) { return false; } PatternWithAction tmp = (PatternWithAction) o; return true && tmp.patternWithAction.equals(this.patternWithAction) ; } @Override public int hashCode() { return 613 + 383 * patternWithAction.hashCode() ; } @Override public org.rascalmpl.ast.PatternWithAction getPatternWithAction() { return this.patternWithAction; } @Override public boolean hasPatternWithAction() { return true; } @Override public Object clone() { return newInstance(getClass(), src, (IConstructor) null , clone(patternWithAction)); } } }