/*
* $Id: StaticVariableNode.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.ErrorListener;
import anvil.codec.Code;
import anvil.script.compiler.ByteCompiler;
import anvil.script.Context;
import anvil.script.Type;
import anvil.script.StaticVariableType;
import anvil.script.statements.ModuleStatement;
import java.io.IOException;
/**
* class StaticVariableNode
*
* @author: Jani Lehtim�ki
*/
public class StaticVariableNode extends Node
{
private StaticVariableType _var;
public StaticVariableNode(StaticVariableType var)
{
super();
_var = var;
}
public int typeOf()
{
return Node.EXPR_VARIABLE;
}
public boolean isConstant()
{
return false;
}
public Node optimize()
{
return this;
}
public void compile(ByteCompiler context, Node child)
{
child.compile(context, GET);
Code code = context.getCode();
code.dup();
code.putstatic(_var.getTypeRef(code.getPool()));
}
public void compile(ByteCompiler context, int operation)
{
int field = _var.getTypeRef(context.getPool());
Code code = context.getCode();
switch(operation) {
case GET:
code.getstatic(field);
break;
case GET_BOOLEAN:
code.getstatic(field);
context.any2boolean();
break;
case CHECK:
code.getstatic(field);
break;
case DELETE:
code.iconst(false);
break;
}
}
}