blob: bae75842b5eeb17f293d54b8b5ef8f711dbf8fc5 [file] [log] [blame]
/*********************************************************************
* Copyright (c) 2008 The University of York.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.epsilon.eol.dom;
import org.eclipse.epsilon.common.module.IModule;
import org.eclipse.epsilon.common.parse.AST;
import org.eclipse.epsilon.eol.compile.context.EolCompilationContext;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.context.IEolContext;
import org.eclipse.epsilon.eol.types.EolPrimitiveType;
public class BooleanLiteral extends LiteralExpression {
protected boolean value;
public BooleanLiteral() {}
public BooleanLiteral(boolean value) {
setValue(value);
}
@Override
public void build(AST cst, IModule module) {
super.build(cst, module);
try {
value = new Boolean(cst.getText()).booleanValue();
}
catch (Exception ex){
value = false;
}
}
@Override
public Object execute(IEolContext context) throws EolRuntimeException {
return getValue();
}
public boolean getValue() {
return value;
}
public void setValue(boolean value) {
this.value = value;
}
@Override
public void compile(EolCompilationContext context) {
resolvedType = EolPrimitiveType.Boolean;
}
}