/*******************************************************************************
* Copyright (c) 2009-2012 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
* * Emilie Balland - (CWI)
* * Arnold Lankamp - Arnold.Lankamp@cwi.nl
* * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
*******************************************************************************/
package org.rascalmpl.eclipse.debug.core.model;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import io.usethesource.vallang.type.Type;
/**
* Model for the local variable of a module.
*/
public class RascalVariable extends RascalDebugElement implements IVariable {
private final String name;
private final io.usethesource.vallang.IValue value;
private final RascalStackFrame frame;
private final Type declaredType;
protected RascalVariable(RascalStackFrame frame, String name, Type declaredType, io.usethesource.vallang.IValue value) {
super(frame.getRascalDebugTarget());
this.name = name;
this.frame = frame;
this.value = value;
this.declaredType = declaredType;
}
public io.usethesource.vallang.IValue getRuntimeValue() {
return value;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getValue()
*/
public IValue getValue() throws DebugException {
return new RascalValue(frame, declaredType, value);
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getName()
*/
public String getName() throws DebugException {
return name;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof RascalVariable) {
RascalVariable o = (RascalVariable) obj;
return (value==null && o.value==null) || (name.equals(o.name)
&& value.equals(o.value));
}
return false;
}
@Override
public int hashCode() {
return name.hashCode();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException {
return declaredType.toString();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
*/
public boolean hasValueChanged() throws DebugException {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
*/
public void setValue(String expression) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
*/
public void setValue(IValue value) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
*/
public boolean supportsValueModification() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
*/
public boolean verifyValue(String expression) throws DebugException {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
*/
public boolean verifyValue(IValue value) throws DebugException {
return false;
}
}