Package anvil.script

Examples of anvil.script.ClassType



  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    ClassType classtype = classOf();
    buffer.append("class ");
    buffer.append(classtype.getQualifiedName());
    buffer.append('@');
    buffer.append(Integer.toHexString(System.identityHashCode(this)));
    buffer.append('@');
    buffer.append(classtype.getPathinfo());
    buffer.append(' ');
    buffer.append('{');
    boolean isFirst = true;
    BindingEnumeration e = getAllMembers();
    while(e.hasMoreElements()) {
View Full Code Here


  {
    if (serializer.register(this)) {
      return;
    }
    serializer.write('o');
    ClassType type = classOf();
    serializer.write(type.getQualifiedName());
    serializer.write(type.getPathinfo());
    _serialize(serializer);
  }
View Full Code Here

  }


  public CompiledClassType getCompiledBaseClass()
  {
    ClassType classtype = _base.getClassType();
    if (classtype instanceof CompiledClassType) {
      return (CompiledClassType)classtype;
    }
    return null;
  }
View Full Code Here

  }
 
 
  public Type lookupInheritedDeclaration(String name)
  {
    ClassType base = getBaseClass();
    return (base != null) ? base.lookupDeclaration(name) : null;
  }
View Full Code Here

  }


  public boolean isInstanceOf(Type ofType)
  { 
    ClassType cls = this;
    while(cls != null) {
      if (cls == ofType) {
        return true;
      }
      cls = cls.getBaseClass();
    }
    return false;
  }
View Full Code Here

    }
    ConstantPool pool = code.getPool();
    ClassType[] parents = context.getEnclosingClasses();
    int n = parents.length;
    for(int i=0; i<n; i++) {
      ClassType parent = parents[i];
      if (parent == target) {
        code.self();
        code.getfield(pool.addFieldRef(context.getTypeRef(pool), "this$"+i,
          'L'+parent.getDescriptor()+';'));
        return;
      }
    }
    code.self();
  }
View Full Code Here

  }


  public void compile(ByteCompiler context, int operation)
  {
    ClassType base = _classtype.getBaseClass();
    if (base != null) {
      Code code = context.getCode();
      CompilableFunction ctor = base.getConstructor();
      code.self();
      context.compileArgumentList(ctor, getChilds(0));
      code.invokespecial(ctor.getTypeRef(code.getPool()));
    }
  }
View Full Code Here

    return namespace;
  }

  protected ClassType onClass(ClassLoader classloader, Class cls, String name, Doc doc)
  {
    ClassType clazz = new CompiledClassType(classloader, this, cls, name, doc);
    declare(clazz);
    return clazz;
  }
View Full Code Here

 
 
  protected Node explicitThisConstruct(ErrorListener listener, ClassType classtype)
  {

    ClassType context = _statement.getClassStatement();
   
    if (!hasMoreSymbols()) {
      return new ThisNode(context, classtype);
    }
   
View Full Code Here


  protected Node superConstruct(ErrorListener context)
  {
    consumeSymbol();
    ClassType classtype = _statement.getClassStatement();
    boolean in_method = (_statement.getFunctionStatement() != null);

    if (classtype == null) {
      context.error(_location, "Cannot use 'super' outside the scope of class");
      return null;
    }

    if (classtype.getBase() == null) {
      context.error(_location, "Cannot use 'super' in classes without base class");
      return null;
    }

    if ((symbolsLeft() == 0) && hasArgs() && in_method) {
      if (_role != SUPER) {
        context.error(_location, "Superclass constructor invoke must appear as first statement in the body of constructor");
        return null;
      }
    
      ClassType base = classtype.getBaseClass();
      CompilableFunction constructor = base.getConstructor();
      if (constructor == null) {
        context.error(_location, "Base class '"+base+"' does not have constructor");
        return null;
      }
      checkArguments(context, constructor);
View Full Code Here

TOP

Related Classes of anvil.script.ClassType

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.