/*
* $Id: StringCastNode.java,v 1.5 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 StringCastNode
*
* @author: Jani Lehtim�ki
*/
public class StringCastNode extends UnaryParent
{
public StringCastNode(Node child)
{
super(child);
}
public int typeOf()
{
return Node.EXPR_STRING_CAST;
}
public Any eval()
{
Any a = _child.eval();
return Any.create(a.toString());
}
public void compile(ByteCompiler context, int operation)
{
if (operation == GET_BOOLEAN) {
_child.compile(context, GET_BOOLEAN);
} else {
_child.compile(context, GET);
Code code = context.getCode();
code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY,
"toAnyString", "()Lanvil/core/Any;"));
}
}
}