view core/src/luan/impl/ReturnStmt.java @ 659:f1150518c467

remove tail recursion
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 05 Apr 2016 20:30:42 -0600
parents 8e8c30b72e9b
children b438a47196bc
line wrap: on
line source

package luan.impl;

import luan.Luan;
import luan.LuanException;
import luan.LuanFunction;


final class ReturnStmt extends CodeImpl implements Stmt {
	private final Expressions expressions;
	boolean throwReturnException = true;

	ReturnStmt(Expressions expressions) {
		this.expressions = expressions;
	}

	@Override public void eval(LuanStateImpl luan) throws LuanException {
		luan.returnValues = expressions.eval(luan);
		if( throwReturnException )
			throw new ReturnException();
	}
}