Package anvil.script.statements

Examples of anvil.script.statements.ClassStatement


      }

    case Type.METHOD:
      {
        MethodType method = (MethodType)type;
        ClassStatement context = _statement.getClassStatement();

        if (type instanceof FunctionStatement) {
          FunctionStatement function = (FunctionStatement)type;
          if (function.getContext() != null) {
            if (hasArgs()) {
              return new InlinedCallNode(_statement.getFunctionStatement(), function, consumeArgs());
            } else {
              return new InlinedFunctionNode(_statement.getFunctionStatement(), function);
            }
          }
        }
        if (hasMoreSymbols()) {
          return new TypeNode(type);
        } else {
          Grammar.checkInstanceAmbiguity(listener, _location, context, method);
          if (hasArgs()) {
            //methodname(...)
            checkArguments(listener, method);
            return new StaticInvokeNode(method.getClassType(), context, method, consumeArgs());
          } else {
            //methodname
            return new DelegateNode(new ThisNode(context, method.getClassType()), method);
          }
        }
      }
     
    case Type.CONSTRUCTOR:
      {
        if (!hasMoreSymbols()) {
          if (hasArgs()) {
            listener.error(_location, "Trying to call constructor '"+type+"'");
            return null;
          }
        }
        return new TypeNode(type);
      }

    case Type.CONSTANT_VARIABLE:
      {
        if (_role != GET) {
          listener.error(_location, "Attempting to assign to constant '"+symbol+"'");
        }
        return new ConstantVariableNode((ConstantVariableType)type);
      }
   
    case Type.STATIC_VARIABLE:
      {
        return new StaticVariableNode((StaticVariableType)type);
      }

    case Type.MEMBER_VARIABLE:
      {
        ClassStatement context = _statement.getClassStatement();
        MemberVariableType member = (MemberVariableType)type;
        Grammar.checkInstanceAmbiguity(listener, _location, context, member);
        return new MemberVariableNode(context, member);
      }
View Full Code Here


      Location location = toLocation(t);
      String document = t.document;
      String name = s.image;

      DefinitionStatement target = flowPeek().getDefinitionStatement();
      ClassStatement      parent = flowPeek().getClassStatement();
      FunctionStatement  context = flowPeek().getFunctionStatement();

      if (context != null) {
        if (context.getType() == Type.FUNCTION) {
          is_static = true;
        }
      }
      if (is_static) {
        if (name.equals(parent.getName())) {
          error(location, "Static methods may not used as constructors");
        }
        FunctionStatement function = new FunctionStatement(location, parent, context, is_synchronized, name, document, parameters);
        function.setParentStatement(flowPeek());
        if (target.lookupDeclaration(name) == null) {
          parent.declare(function);
          if (context != null) {
            context.declare(name, function);
          }
        } else {
          error(location, "Entity '" + name + "' is already declared");
        }
        flowPush(function);
        flowPush(function.getChildStatement());

      } else {
        MethodStatement method;
        if ((context == null) && name.equals(parent.getName())) {
          is_constructor = true;
          method = new ConstructorStatement(location, parent, is_synchronized, name, document, parameters);
          if (parent.getConstructor() != null) {
            error(location, "Constructor is already declared for class '"+parent+"'");
          }
        } else {
          method = new MethodStatement(location, parent, context, is_synchronized, name, document, parameters);
        }
        method.setParentStatement(flowPeek());
        if (target.lookupLocalDeclaration(name) == null) {
          parent.declare(method);
          if (context != null) {
            context.declare(name, method);
          }
        } else {
          error(location, "Entity '" + name + "' is already declared");
View Full Code Here

      jj_la1[40] = jj_gen;
      ;
    }
    jj_consume_token(BEGIN);
      DefinitionStatement parent = flowPeek().getDefinitionStatement();
      ClassStatement classtype = new ClassStatement(location, parent, name, t.document, base, interfaces);
      if (parent.lookupDeclaration(name) == null && !parent.isEntityReserved(name)) {
        parent.declare(classtype);
      } else {
        error(location, "Entity '"+name+"' is already declared");
      }
      flowPush(classtype);
    label_13:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IMPORT:
      case FUNCTION:
      case SYNCHRONIZED:
      case STATIC:
      case CLASS:
      case VAR:
      case CONST:
        ;
        break;
      default:
        jj_la1[41] = jj_gen;
        break label_13;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IMPORT:
        Import();
        break;
      case CONST:
        ConstantVariable();
        break;
      case CLASS:
        Class();
        break;
      default:
        jj_la1[42] = jj_gen;
        if (jj_2_5(2)) {
          Variable();
        } else {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case FUNCTION:
          case SYNCHRONIZED:
          case STATIC:
            Method();
            break;
          default:
            jj_la1[43] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
        }
      }
    }
    jj_consume_token(END);
      classtype.finish();
      flowPop();
  }
View Full Code Here

TOP

Related Classes of anvil.script.statements.ClassStatement

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.