/*
* $Id: MatchNode.java,v 1.6 2002/09/16 08:05:05 jkl Exp $
*
* Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
*
* Use is subject to license terms, as defined in
* Anvil Sofware License, Version 1.1. See LICENSE
* file, or http://njet.org/license-1.1.txt
*/
package anvil.script.expression;
import anvil.core.Any;
import anvil.codec.Code;
import anvil.script.compiler.ByteCompiler;
import anvil.script.Context;
import java.io.IOException;
/**
* class MatchNode
*
* @author: Jani Lehtim�ki
*/
public class MatchNode extends BinaryParent
{
public MatchNode(Node left, Node right)
{
super(left,right);
}
public int typeOf()
{
return Node.EXPR_MATCH;
}
public Any eval()
{
return Context.match(null, _left.eval(), _right.eval())
? Any.TRUE : Any.FALSE;
}
public void compile(ByteCompiler context, int operation)
{
Code code = context.getCode();
code.aload_first();
super.compile(context, GET);
code.invokestatic(code.getPool().addMethodRef(context.TYPE_CONTEXT,
"match", "(Lanvil/script/Context;Lanvil/core/Any;Lanvil/core/Any;)Z"));
if (operation != GET_BOOLEAN) {
context.boolean2any();
}
}
}