Package anvil.script.expression

Source Code of anvil.script.expression.AttributeNode

/*
* $Id: AttributeNode.java,v 1.9 2002/09/16 08:05:04 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 AttributeNode
*
* @author: Jani Lehtim�ki
*/
public class AttributeNode extends UnaryParent
{

  private String _attribute;


  public AttributeNode(Node self, String attribute)
  {
    super(self);
    _attribute = attribute;
  }


  public String getAttribute()
  {
    return _attribute;
  }
 

  public int typeOf()
  {
    return EXPR_ATTRIBUTE;
  }


  public boolean isConstant()
  {
    return false;
  }

 
  public Node optimize()
  {
    optimizeChilds();
    return this;
  }


  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    switch(operation) {
    case GET:
      _child.compile(context, GET);
      code.aload_first();
      code.astring(_attribute);
      code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "getAttribute",
        "(Lanvil/script/Context;Ljava/lang/String;)Lanvil/core/Any;"));
      break;

    case GET_BOOLEAN:
      _child.compile(context, GET);
      code.aload_first();
      code.astring(_attribute);
      code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "getAttribute",
        "(Lanvil/script/Context;Ljava/lang/String;)Lanvil/core/Any;"));
      context.any2boolean();
      break;

    case CHECK:
      _child.compile(context, GET);
      code.aload_first();
      code.astring(_attribute);
      code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "checkAttribute",
        "(Lanvil/script/Context;Ljava/lang/String;)Lanvil/core/Any;"));
      break;

    case DELETE:
      _child.compile(context, GET);
      code.aload_first();
      code.astring(_attribute);
      code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "deleteAttribute",
        "(Lanvil/script/Context;Ljava/lang/String;)Z"));
      break;
    }
  }

}
TOP

Related Classes of anvil.script.expression.AttributeNode

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.