/*
* $Id: NamespaceNode.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.core.runtime.AnyNamespace;
import anvil.ErrorListener;
import anvil.codec.Code;
import anvil.script.compiler.ByteCompiler;
import anvil.script.Context;
import anvil.script.NamespaceType;
import java.io.IOException;
/**
* class NamespaceNode
*
* @author: Jani Lehtim�ki
*/
public class NamespaceNode extends Node
{
public NamespaceType _namespace;
public NamespaceNode(NamespaceType namespace)
{
super();
_namespace = namespace;
}
public int typeOf()
{
return Node.EXPR_NAMESPACE;
}
public boolean isConstant()
{
return false;
}
public Node optimize()
{
return this;
}
public void compile(ByteCompiler context, int operation)
{
Code code = context.getCode();
code.aload_first();
code.astring(_namespace.getName());
code.invokevirtual(code.getPool().addMethodRef(context.TYPE_CONTEXT,
"getNS", "(Ljava/lang/String;)Lanvil/core/Any;"));
if (operation == GET_BOOLEAN) {
context.any2boolean();
}
}
}