Package macromedia.asc.semantics

Examples of macromedia.asc.semantics.Slot


                        List values = idn.interfaces.values;
                        baseClasses = new String[values.size()];
                        for (int i = 0; i < values.size(); i++)
                        {
                            ReferenceValue rv = (ReferenceValue)values.get(i);
                            Slot s = rv.getSlot(cx, Tokens.GET_TOKEN);
                            baseClasses[i] = (s == null || s.getDebugName().length() == 0) ? rv.name : s.getDebugName();
                        }
                    }
                    else
                    {
                        baseClasses = new String[] {"Object"};
                    }
                }
                else
                {
                    if (cd.baseref != null)
                    {
                        Slot s = cd.baseref.getSlot(cx, Tokens.GET_TOKEN);
                        baseClass = (s == null || s.getDebugName().length() == 0) ? "Object" : s.getDebugName();
                    }
                    else
                    {
                        baseClass = "Object";
                    }

                    if (cd.interfaces != null)
                    {
                        List values = cd.interfaces.values;
                        interfaces = new String[values.size()];
                        for (int i = 0; i < values.size(); i++)
                        {
                            ReferenceValue rv = (ReferenceValue)values.get(i);
                            Slot s = rv.getSlot(cx, Tokens.GET_TOKEN);
                            interfaces[i] = (s == null || s.getDebugName().length() == 0) ? rv.name : s.getDebugName();
                        }
                    }
                }

                AttributeListNode attrs = cd.attrs;
View Full Code Here


                {
                    isStatic = attrs.hasStatic;
                    hasUserNamespace  = attrs.hasUserNamespace();
                }
               
                Slot s = vb.ref.getSlot(cx);
                if (s != null)
                {
                    isConst = s.isConst();              
                }

                if (vb.initializer != null)
                {
                    if (vb.initializer instanceof LiteralNumberNode)
                    {
                        defaultValue = ((LiteralNumberNode)(vb.initializer)).value;
                    }
                    else if (vb.initializer instanceof LiteralStringNode)
                    {
                        defaultValue = DocCommentNode.escapeXml(((LiteralStringNode)(vb.initializer)).value);
                    }
                    else if (vb.initializer instanceof LiteralNullNode)
                    {
                        defaultValue = "null";
                    }
                    else if (vb.initializer instanceof LiteralBooleanNode)
                    {
                        defaultValue = (((LiteralBooleanNode)(vb.initializer)).value) ? "true" : "false";
                    }
                    else if (vb.initializer instanceof MemberExpressionNode)
                    {
                        MemberExpressionNode mb = (MemberExpressionNode)(vb.initializer);
                        Slot vs = null;
            if (mb.ref != null && mb.selector.isGetExpression())
            {
              vs = (mb.ref != null ? mb.ref.getSlot(cx, Tokens.GET_TOKEN) : null);
            }
            else
            {
              vs = vb.ref.getSlot(cx, Tokens.GET_TOKEN);
            }
                       
                        Value v = (vs != null ? vs.getValue() : null);
                        ObjectValue ov = ((v instanceof ObjectValue) ? (ObjectValue)(v) : null);
                        // if constant evaluator has determined this has a value, use it.
                        defaultValue = (ov != null) ? ov.getValue() : "unknown";
                    }
                    else
                    {
                        Slot vs = vb.ref.getSlot(cx, Tokens.GET_TOKEN);
                        Value v = (vs != null ? vs.getValue() : null);
                        ObjectValue ov = ((v instanceof ObjectValue) ? (ObjectValue)(v) : null);
                        // if constant evaluator has determined this has a value, use it.
                        defaultValue = (ov != null) ? ov.getValue() : "unknown";
                    }
                }
View Full Code Here

           
            // Helper method to print types in a way asdoc wants.
            // This is mostly for Vectors, which need to print as Vector$basetype.
            public String getRefName(Context cx, ReferenceValue ref)
            {
                Slot s = ref.getSlot(cx, Tokens.GET_TOKEN);
                if( s == null || s.getDebugName().length() == 0 )
                {
                    String name = ref.name;
                    if( ref.type_params != null && s != null && s.getValue() instanceof TypeValue)
                    {
                        // Vector
                        TypeValue t = (TypeValue)s.getValue();
                        name += getIndexedTypeName(cx, t.indexed_type);
                    }
                    return name;
                }
                else
                {
                    return s.getDebugName();
                }
            }
View Full Code Here

            int referencingIndex = referencingTypeInfo.getSlotIndex(ascContext, kind, localPart, namespace);
            int referencedIndex = referencedTypeInfo.getSlotIndex(ascContext, kind, localPart, namespace);

            if (referencingIndex != referencedIndex)
            {
                Slot referencingSlot = referencingTypeInfo.getSlot(ascContext, referencingIndex);
                Slot referencedSlot = referencedTypeInfo.getSlot(ascContext, referencedIndex);

                // Types are stored in VariableSlot's as opposed to MethodSlot's.
                if ((referencingSlot instanceof VariableSlot) &&
                    (referencedSlot instanceof VariableSlot) &&
                    (referencingSlot.getValue() != referencedSlot.getValue()))
                {
                    result = true;
                }
            }
        }
View Full Code Here

                    ObjectValue namespace = ascContext.getNamespace(topLevelDefinition.getNamespace().intern());

                    if (frame.hasName(ascContext, Tokens.GET_TOKEN, name, namespace))
                    {
                        int slotId = frame.getSlotIndex(ascContext, Tokens.GET_TOKEN, name, namespace);
                        Slot slot = frame.getSlot(ascContext, slotId);

                        if (slot != null)
                        {
                            int implicitId = frame.getImplicitIndex(ascContext, slotId, Tokens.EMPTY_TOKEN);

                            if ((slotId != implicitId) && (slot instanceof VariableSlot))
                            {
                                Slot implicitSlot = frame.getSlot(ascContext, implicitId);
                                TypeValue typeValue = implicitSlot.getType().getTypeValue();
                                assert topLevelDefinition.toString().equals(typeValue.name.toString()) :
                                "topLevelDefinition = " + topLevelDefinition + ", typeValue = " + typeValue.name.toString();
                                perCompileData.userDefined.put(typeValue.name.toString(), typeValue);
                            }
                        }
View Full Code Here

      }
      node.expr.evaluate(cx,this);
      return cx.noType(); // doesn't matter what we return during first_pass.
    }

        Slot s = (node.ref == null ? null : node.ref.getSlot( cx, (node.is_new ? NEW_TOKEN : EMPTY_TOKEN)));
    if (node.ref != null && s == null)
    {
            TypeValue searchType = baseType_context.last(); // todo: why is this more reliable than node->ref->base

            // if this is an attempt to access a static member of a class, switch searchType to the class's type
            //   This is necessary to allow lookup in the unsupportedMethodsMap table.
         if (searchType != null && "Class".equals(searchType.name.toString()))
            {
                ReferenceValue br = baseRef_context.back();
                s = (br != null ? br.getSlot(cx,GET_TOKEN) : null);
                // c++ variant accesses union member typValue directly, java stores value in objValue
                TypeValue t = (s != null && s.getObjectValue() instanceof TypeValue) ? (TypeValue)(s.getObjectValue()) : null;
                searchType = (t != null) ? t : searchType;
            }

            // cn:  note we can check xml/xmlList for unknown methods, but not unknown properties.  Dynamically defined props due to xml children will
            //      trump any instance props at runtime.  Not true for methods, however.  A method not known at compile time will never be defined
            //      at runtime by the xml data itself.  It would have to be defined by the author as a dynamic property of the instance (i.e. just like Date, RegExp and Error: unlikely).
            if (searchType == types[kDateType] || searchType == cx.regExpType() || searchType == cx.xmlType() || searchType == cx.xmlListType() ||
                (types[kErrorType] != null && types[kErrorType].includes(cx,searchType)))  // these types are dynamic for backwards compatability, so ! doesn't catch this.  Its unlikely anyone is adding dynamic props to them
            {
                warning(node.pos(), cx.input, kWarning_BadES3TypeMethod, node.ref.name, searchType.name.name);
            }
            else
            {
                Map<TypeValue,Integer> search = unsupportedMethodsMap.get(node.ref.name);
        if (search != null && ! search.isEmpty())
                {
                    for(TypeValue type : search.keySet())
                    {
                        if (type != null && type.includes(cx,searchType))
                        {
                            warning(node.getPosition(), cx.input, kWarning_DepricatedFunctionError, node.ref.name,
                                warningConstantsMap.get(search.get(type)));
                        }
                    }
                }
            }
      }

    if (node.ref != null && node.is_new)
    {
      Slot callSlot = node.ref.getSlot(cx,EMPTY_TOKEN);
      if ( callSlot != null && callSlot.getType().getTypeValue() != cx.typeType() ) // don't warn for non-functions or functions actually declared to return a Class.
      {
        // in ES3.0,  function A() { var local = new Object(); local.c = 20; return c; };  var dd = new A();
        //  dd is assigned the new object returned by A, rather than a new instance of A.  In AS2.0, dd is
        //  assigned a new instance of A.  While not something people would do on purpose, its not an unlikely
        //  accident that a function intended for new instance creation might have a return in it.  Warn if it does
        Slot getSlot = node.ref.getSlot(cx,GET_TOKEN);
        ObjectValue base = node.ref.getBase(); // new obj.func() always worked as expected in AS2, however.  Don't warn if there's a base
        if (base == null && getSlot != null && slot_GetHasReturnValue(s))
        {
          warning(node.getPosition(), cx.input, kWarning_ConstructorReturnsValue, node.ref.name, node.ref.name);
        }
View Full Code Here

          if (arg2.isMemberExpression())
          {
            MemberExpressionNode memb = (MemberExpressionNode)arg2;
            if (memb.ref != null && memb.selector.isGetExpression())
            {
              Slot s = memb.ref.getSlot(cx,GET_TOKEN);
              if (s != null)
                slot_markAsRegisteredForEvent(s,true);
            }
          }

        }
      }

      // no warning reporting during first pass
      return evaluateGenericCallExpression(cx,node);
    }

    // check if this is a deprecated function
    if (node.is_new || node.ref == null )
    {
      // Evaluate args, check for change in "new" behavior, get the return type
      if (! evaluated)
        returnVal = evaluateGenericCallExpression(cx,node)// must process args *after* processing call expression name
      return returnVal;

    }
    else if (node.ref != null)
    {
      int  numArgs = (node.args == null ? 0 : node.args.items.size());

      if ("__resolve".equals(node.ref.name))
      {
        warning(node.getPosition(), cx.input, kWarning_ChangesInResolve);
      }     
     
      /* Reactivated, but more specific (only for blank strings)... Old comment follows:
       *    This warning is kind of obscure and not likely to affect a lot of
       *    people compared to the volume of warnings it will generate.
       *
       * PS: I don't know whether this case ever gets called, but the other place
       *     it is checked in kWarning_NumberFromStringChanges does. */
      // cn:  not sure where this came from (bug assigned to Jono?), but this is so special
      //      cased as to not be useful.   We should remove this warning.
      else if ((baseType == cx.nullType()
          && ("Number".equals(node.ref.name)
          && numArgs == 1)))
      {
        Node   arg = node.args.items.get(0);
        Value  argTypeVal = arg.evaluate(cx, this);

        evaluated = true;
        returnVal = cx.doubleType()// RES don't bother with numberUsage issues here
        if (argTypeVal == cx.stringType()
            && (arg instanceof LiteralStringNode)
            && "".equals(((LiteralStringNode)arg).value.trim()))
        {
          warning(node.getPosition(), cx.input, kWarning_NumberFromStringChanges);
        }
      }
            // TODO: toString is special-cased... unsure exactly why
      else if ( ((baseType == cx.nullType()) && ("String".equals(node.ref.name)) && (numArgs == 1))
          || ((baseType != cx.nullType()) && ("toString".equals(node.ref.name)) && (numArgs == 0)) )
      {
        TypeValue argTypeVal = null;

        if (numArgs == 1)
        {
          Node   arg = node.args.items.get(0);
          Value  argType = arg.evaluate(cx,this);

          argTypeVal = (argType instanceof TypeValue) ? (TypeValue) argType : null;
        }
        else
        {
          argTypeVal = baseType_context.last();
        }
        evaluated = true;
        returnVal = cx.stringType();

        if (argTypeVal == cx.arrayType())
        {
          warning(node.getPosition(), cx.input, kWarning_ArrayToStringChanges);
        }

                final Slot s = node.ref.getSlot( cx, (node.is_new ? NEW_TOKEN : EMPTY_TOKEN));
                checkDeprecatedSlot(cx, node, node.ref, s);
      }
      /*
      else if ( (baseType != cx.nullType()) && ("split".equals(node.ref.name)) )
      {
View Full Code Here

  public Value evaluate( Context cx, DeleteExpressionNode node )
  {
    node.expr.evaluate(cx,this);

        Slot slot = (node.ref != null ? node.ref.getSlot(cx,GET_TOKEN) : null);

        if( slot != null && !in_with  )
        {
            warning(node.expr.pos(), cx.input, kWarning_DeleteOfFixedProperty, node.ref.name);
        }
View Full Code Here

      }
    }
    else if( node.ref != null)
    {
      // nothing to evaluate, its an identifier
      Slot slot = node.ref.getSlot(cx,GET_TOKEN)// check for base object type?

      // special case for looking up a value of a class.  ConstantEvaluator
      //  doesn't recognize direct Class references outside of the global scope, so
      //  it fails to set the ref's base correctly.  It has to do this because when
      //  the function is called, its possible it will be called from a context where
      //  the global class definition has been superceeded by a local definition.
      //  This is pretty unlikely, however, and messes up the undeclared property reference
      //  detection.  If the base of this expression (appears) to be the global definition for
      //  a class, temporarily reset the ref's base and use that definition.
      TypeValue basetype = baseType_context.last();
      if (slot == null && basetype != null && "Class".equals(basetype.name.toString()) )
      {
        ReferenceValue baseRef = baseRef_context.last();

        if (baseRef != null)
        {
          ObjectValue realBase = (ObjectValue)(baseRef.getValue(cx));
          ObjectValue oldBase = node.ref.getBase();
          node.ref.setBase(realBase);
          slot = node.ref.getSlot(cx,GET_TOKEN);
          node.ref.setBase(oldBase);
        }
      }

      // The last ditch, for handling Inteface base types.    If there's a base type, see if its defined in its prototype.
      //  This definition is not good enough for code generation, but its good enough for a warning.  Its pretty unlikely
      //  that the definition is superceeded at runtime. 
      if (slot == null && basetype != null && basetype.prototype != null && node.ref.name != null)
      {
        slot = getSlot(basetype.prototype, cx, node, GET_TOKEN);
      }

      if (slot != null )
        checkDeprecatedSlot(cx, node, node.ref, slot);
     
      TypeInfo ti = (slot != null) ? slot.getType() : null;
      TypeValue   type = (ti != null) ? ti.getTypeValue() : null;

      result = type;
      if (result == null)
      {
        result = cx.voidType();
      }
      else if (node.ref.name.compareTo("undefined")==0)
      {
        result = undefinedLiteral;
      }

      //TODO : remove this when these identifiers are declared in playerglobal.as
      Boolean ignoreKeyword = hackIgnoreIdentifierMap.get(node.ref.name);

      int  base_index         = node.ref.getScopeIndex(GET_TOKEN);
      int  slot_index         = node.ref.getSlotIndex(GET_TOKEN);
      boolean is_globalref         = base_index == 0;
      boolean is_dotref            = base_index == -2;
      boolean is_unbound_lexref    = base_index == -1;
      boolean is_unbound_dotref    = is_dotref && slot_index < 0;
      boolean is_unbound_globalref = is_globalref && slot_index < 0;
      boolean is_unbound_ref       = is_unbound_dotref || is_unbound_lexref || is_unbound_globalref;

      if ( slot == null && (ignoreKeyword == null || !ignoreKeyword) && is_unbound_ref )
      {
                boolean unsupported = false;
        // special case to avoid warning on access to a Class's prototype property.  This
        //  property can't be expressed in global.as because you can't both declare a class
        //  and declare it to be an instance of the Class class.
        if (basetype != null && "Class".equals(basetype.name.toString()) && "prototype".equals(node.ref.name))
                {
          return node.expr.evaluate(cx,this);
                }
                if (basetype == types[kDateType] || basetype == cx.regExpType() ||
                    (types[kErrorType] != null && types[kErrorType].includes(cx,basetype)))  // these types are dynamic for backwards compatability, so ! doesn't catch this.  Its unlikely anyone is adding dynamic props to them
                {
                    warning(node.pos(), cx.input, kWarning_BadES3TypeProp, node.ref.name, basetype.name.name);
                    unsupported = true;
                }
                else
                {
                    Map<TypeValue,Integer> search = unsupportedPropsMap.get(node.ref.name);

                    if (search != null && !search.isEmpty() ) // && search.second.empty() == false)
                    {
                        TypeValue searchType = baseType_context.last(); // todo: why is this more reliable than node->ref->base

                        // if this is an attempt to access a static member of a class, switch searchType to the class's type
                        //   This is necessary to allow lookup in the unsupportedPropsMap table.
                        if (searchType != null && "Class".equals(searchType.name.toString()))
                        {
                            ReferenceValue br = baseRef_context.back();
                            Slot s = (br != null ? br.getSlot(cx,GET_TOKEN) : null);
                            // c++ variant accesses union member typValue directly, java stores value in objValue
                            TypeValue t = (s != null && s.getObjectValue() instanceof TypeValue) ? (TypeValue)(s.getObjectValue()) : null;
                            searchType = (t != null) ? t : searchType;
                        }

                        for(TypeValue matchType : search.keySet())
                        {
View Full Code Here

    return result;
  }

  private Slot getSlot(ObjectValue proto, Context cx, SelectorNode node, int type)
  {
    Slot slot = null;
    Namespaces ns = proto.hasNames(cx, type, node.ref.name, node.ref.getImmutableNamespaces());
    if (ns != null)
    {
      // we just grab the first namespace value, which I assume is what would happen at runtime
      ObjectValue last = ns.first();
View Full Code Here

TOP

Related Classes of macromedia.asc.semantics.Slot

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.