Package anvil.script.statements

Source Code of anvil.script.statements.MethodStatement

/*
* $Id: MethodStatement.java,v 1.8 2002/09/16 08:05:06 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.statements;

import anvil.Location;
import anvil.core.Any;
import anvil.codec.Method;
import anvil.codec.Code;
import anvil.codec.ClassRoom;
import anvil.codec.ConstantPool;
import anvil.codec.Field;
import anvil.script.ClassType;
import anvil.script.compiler.ByteCompiler;
import anvil.ErrorListener;
import anvil.script.Type;
import anvil.script.MethodType;
import anvil.script.ParameterListDeclaration;
import anvil.java.util.Hashlist;
import java.io.IOException;
import java.util.Enumeration;

/**
* class MethodStatement
*
* @author: Jani Lehtim�ki
*/
public class MethodStatement extends FunctionStatement implements MethodType
{


  public MethodStatement(DefinitionStatement parent, Location location)
  {
    super(parent, location);
  }


  public MethodStatement(
      Location location,
      DefinitionStatement parent,
      FunctionStatement context,
      boolean sync,
      String name,
      String document,
      ParameterListDeclaration parameters)
  {
    super(location, parent, context, sync, name, document, parameters);
  }


  public int getType()
  {
    return METHOD;
  }


  public String getDescriptor()
  {
    return "m_" + _name;
  }
 

  public int getTypeRef(ConstantPool pool)
  {
    return pool.addMethodRef(_parent.getTypeRef(pool), getDescriptor(), getSignature());
  }


  public ClassType getClassType()
  {
    return (ClassType)_parent;
  }


  public boolean isStaticRegion()
  {
    return false;
  }


  public void check(ErrorListener context)
  {
    _parameters.check(context);
    _block.check(context);
    _block.eliminate(context);
  }


  public void compile(ByteCompiler context)
  {
    ClassRoom clazz = context.getClassRoom();
    Field typefield = clazz.createField("m_"+_name, "Lanvil/script/Function;", ACC_PUBLIC|ACC_STATIC);
    clazz.createField("M_"+_name, "Lanvil/core/Any;", ACC_PUBLIC|ACC_STATIC);
    Method method = clazz.createMethod("m_"+_name, getSignature(), ACC_PUBLIC|(_synchronized?ACC_SYNCHRONIZED:0));
    compileBody(context, method, typefield);
  }


}
TOP

Related Classes of anvil.script.statements.MethodStatement

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.