Package anvil.script

Examples of anvil.script.Type



  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

  /// @synopsis Type lookupInherited(string name)
  /// @return Type or undefined, if there was not a declaration with that name
  public static final Object[] p_lookupInherited = { "name" };
  public Any m_lookupInherited(String name)
  {
    Type type = null;
    switch(_typecode) {
    case Type.CLASS:
      type = ((ClassType)_type).lookupInheritedDeclaration(name);
    case Type.INTERFACE:
      type = ((InterfaceType)_type).lookupInheritedDeclaration(name);
View Full Code Here

  public Any m_getBaseClass()
  {
    if (_typecode == Type.CLASS) {
      ClassRef ref = ((ClassType)_type).getBase();
      if (ref != null) {
        Type type = ref.getType();
        return (type != null) ? new AnyType(type) : UNDEFINED;
      }
    }
    return UNDEFINED;
  }
View Full Code Here

      refs = ((ClassType)_type).getInterfaces();
    } else if (_typecode == Type.INTERFACE) {
      refs = ((InterfaceType)_type).getBases();
    }
    if (refs != null) {
      Type type;
      int n = refs.length;
      Any[] list = new Any[n];
      for(int i=0; i<n; i++) {
        type = refs[i].getType();
        list[i] = (type != null) ? new AnyType(type) : 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.