view core/src/luan/impl/IndexExpr.java @ 614:9ecf5673fb6d

start version 0.15
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 14 Dec 2015 23:55:36 -0700
parents 4723d22062ce
children 859c0dedc8b6
line wrap: on
line source

package luan.impl;

import luan.LuanException;
import luan.LuanElement;


final class IndexExpr extends BinaryOpExpr {

	IndexExpr(LuanElement el,Expr op1,Expr op2) {
		super(el,op1,op2);
	}

	@Override public Object eval(LuanStateImpl luan) throws LuanException {
		Object o1 = op1.eval(luan);
		Object o2 = op2.eval(luan);
		luan.push(el,null);
		try {
			return luan.index(o1,o2);
		} finally {
			luan.pop();
		}
	}

}