Package anvil.script

Examples of anvil.script.Type


  }


  public Type lookupDeclaration(String name)
  {
    Type type = (Type)_types.get(name);
    if (type != null) {
      return type;
    }
    Namespace ns = _address.getZone().getNamespace(name);
    if (ns != null) {
View Full Code Here



  private void addInitializers(Enumeration types)
  {
    while(types.hasMoreElements()) {
      Type type = (Type)types.nextElement();
      switch(type.getType()) {
      case STATIC_VARIABLE:
      case CONSTANT_VARIABLE:
        VariableStatement var = (VariableStatement)type;
        _staticinit.add(new EvalStatement(_staticinit, getLocation(), var.createStaticInitializer()));
        if (!var.hasConstantInitializer()) {
View Full Code Here

    if (_staticinit != null) {
      _staticinit.compile(context);
    }
    Enumeration e = _types.elements();
    while(e.hasMoreElements()) {
      Type type = (Type)e.nextElement();
      int typeid = type.getType();
      if (typeid == CLASS || typeid == INTERFACE) {
        code.getstatic(pool.addFieldRef(type.getTypeRef(pool),
          "_members", "[Ljava/lang/Object;"));
        code.pop();
      }
    }
    context.popCode();
View Full Code Here


  public Any getAttribute(Context context, String name)
  {
    if (_type instanceof Scope) {
      Type type = ((Scope)_type).lookupDeclaration(name);
      return (type != null) ? new AnyType(type) : UNDEFINED;
     
    } else if (_type instanceof CompilableFunction) {
      Any value = ((CompilableFunction)_type).getAttribute(name);
      if (value != null) {
View Full Code Here

        int length = parameters.length;
        if (length == 0) {
          throw context.NoInstance(_type.toString());
        }
        Any self = parameters[0];
        Type target = function.getParent();
        if (!self.isInstanceOf(target)) {
          throw context.BadParameter("Instance of '"+target+"' expected");
        }
        Any[] params = Any.ARRAY0;
        if (length > 1) {
View Full Code Here

  }


  public static final Any unserialize(Unserializer unserializer) throws UnserializationException
  {
    Type type = unserializeType(unserializer);
    AnyType anytype = new AnyType(type);
    unserializer.register(anytype);
    return anytype;
  }
View Full Code Here

 
 
  public static final void serializeType(Serializer serializer, Type stype) throws IOException
  {
    int size = 0;
    Type type = stype;
    while(type != null) {
      size++;
      type = type.getParent();
    }

    Type[] types = new Type[size];
    type = stype;
    int i = 0;
    while(type != null) {
      types[i++] = type;
      type = type.getParent();
    }
   
    serializer.write(size);
    serializer.write(':');
    for(i=size-1; i>=0; i--) {
      type = types[i];
      serializer.write(type.getName());
    }
  }
View Full Code Here

    if (size < 1) {
      throw new UnserializationException();
    }
    unserializer.consume('s');
    String source = unserializer.getUTF16String();
    Type type = unserializer.getContext().import_(source);
    for(int i=1; i<size; i++) {
      unserializer.consume('s');
      String name = unserializer.getUTF16String();
      if (type instanceof Scope) {
        type = ((Scope)type).lookupDeclaration(name);
View Full Code Here

        }
      }
      Enumeration e = ((Scope)_type).getDeclarations();
      Array types = new Array();
      while(e.hasMoreElements()) {
        Type type = (Type)e.nextElement();
        if ((ofType == 0) || (type.getType() == ofType)) {
          types.put(new AnyString(type.getName()), new AnyType(type));
        }
      }
      return types;
    }
    return UNDEFINED;
View Full Code Here

  /// @return Type or undefined, if there was not a declaration with that name
  public static final Object[] p_lookup = { "name" };
  public Any m_lookup(String name)
  {
    if (_type instanceof Scope) {
      Type type = ((Scope)_type).lookupDeclaration(name);
      return (type != null) ? new AnyType(type) : UNDEFINED;
    }
    return UNDEFINED;
  }
View Full Code Here

TOP

Related Classes of anvil.script.Type

Copyright © 2018 www.massapicom. 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.