Package anvil.script.expression

Source Code of anvil.script.expression.ExactCompareNode

/*
* $Id: ExactCompareNode.java,v 1.3 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.codec.Source;
import anvil.script.compiler.ByteCompiler;
import anvil.script.Context;
import java.io.IOException;

/**
* class ExactCompareNode
*
* @author: Jani Lehtim�ki
*/
public class ExactCompareNode extends BinaryParent
{

  public ExactCompareNode(Node left, Node right)
  {
    super(left,right);
  }

 
  public int typeOf()
  {
    return Node.EXPR_COMPARE;
  }


  public Any eval()
  {
    return Any.create(_left.eval().compareTo(_right.eval()));
  }


  public void compile(ByteCompiler context, int operation)
  {
    super.compile(context, GET);
    Code code = context.getCode();
    code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY,
      "compareTo", "(Lanvil/core/Any;)I"));
    if (operation == GET_BOOLEAN) {
      Source isfalse = code.if_eq();
      code.iconst(true);
      Source toend = code.go_to();
      isfalse.bind();
      code.iconst(false);
      toend.bind();
    } else {
      code.invokestatic(code.getPool().addMethodRef(context.TYPE_ANY,
        "create", "(I)Lanvil/core/Any;"));
    }
  }

}
TOP

Related Classes of anvil.script.expression.ExactCompareNode

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.