Package macromedia.asc.semantics

Examples of macromedia.asc.semantics.Slot$Overload


    if (first_pass)
    {
      return node.args.evaluate(cx,this);
    }

        Slot slot = null;
    if( node.ref != null )
    {
      slot = node.ref.getSlot(cx,GET_TOKEN);

      // 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 (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, SET_TOKEN);
      }
      //TypeValue* dt = node->ref->getType(cx); //  this uses use-definition trees, rather than the slot's def.  Assume slot's def for warnings
      int  base_index           = node.ref.getScopeIndex(SET_TOKEN);
      int  slot_index           = node.ref.getSlotIndex(SET_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 )
        checkDeprecatedSlot(cx, node.expr, node.ref, slot);
     
      // 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))
      {
      }
            else if (slot != null && slot.getType().getTypeValue() == cx.uintType() &&
                     node.args != null && node.args.items.size() == 1 && node.args.items.get(0) instanceof LiteralNumberNode)
            {
                LiteralNumberNode ln = (LiteralNumberNode)(node.args.items.get(0));
                if (ln.numericValue.doubleValue() < 0)
                    warning(node.getPosition(), cx.input, kWarning_NegativeUintLiteral);
            }
         
      else if ( slot == null && is_unbound_ref)
      {
                int pos = (node.expr != null ? node.expr.getPosition() : node.getPosition());
                boolean unsupported = false;
                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())
                    {
                        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();
                            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 type : search.keySet())
                        {
                            if (type != null && type.includes(cx,searchType))
                            {
                                unsupported = true;
                                warning(pos, cx.input, kWarning_DepricatedPropertyError, node.ref.name,
                                        warningConstantsMap.get(search.get(type)));
                            }
                        }
                    }
                }

                if (unsupported == false && baseType != null ) // check for unsupported event handlers (StyleSheet.onLoad = new function() ... )
                {
                    Map<TypeValue,Integer> search = unsupportedEventsMap.get(node.ref.name);
                    if (search != null && ! search.isEmpty()) // it matches a former auto-registered event handler name
                    {
                        ObjectValue  scope = cx.scope();

                        if (baseType != null) // !!@todo: check that this dynamic var wasn't seen in an addEventListener call during first_pass
                        {
                            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();
                                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 type : search.keySet())
                            {
View Full Code Here


  {
    //TypeValue  dt = node.ref.getType(cx); //  getDerivedType(cx);

    if (!first_pass)
    {
      Slot s = (node.ref != null) ? node.ref.getSlot(cx,GET_TOKEN) : null;
      if (s != null)
      {
       

        // warn for duplicate definitions.  This is legal due to variable hoisting, but is often not what people expect, especially those
        //  used to block scoping in c++ or java.   It can lean to unexpected code such as this:
        //  var x = 20;
        //  if (someCondition())
        //  {
        //      for (var x= 0; x < 10; x++)
        //          doSometing(x);
        //  }
        //  print(x); // 10, not 20.
        //  Look up the slot for the ref.  If its the first time we've seen it, mark the slot as "declared".  If the slot is already
        //   marked as declared, this is a duplicate definition.
        if (slot_isAlreadyDeclared(s))
        {

          String origDef = "";
                    //String origDef = "on line " + cx.input.getLnNum(slot_getOriginalDeclarationPosition(s));
                    // commented out since the line number is correct for the .as file, but is not correct if we are dealing
                    // with a .as file generated by flex from an mxml file.  Since there is no easy way to map this correctly
                    // at this point just remove the line number info.  We can work on getting the mapping correct in a later release.
          warning(node.getPosition(), cx.input, kWarning_DuplicateVariableDef, origDef);
        }
        else
        {
          slot_markAsDeclared(s, node.getPosition());
        }
      }

            if (node.initializer == null)
            {

                if (s != null && s.isConst())
                    warning(node.getPosition(), cx.input, kWarning_ConstNotInitialized);
            }
            else if (!doing_method)
            {
              if( cx.statics.es4_nullability && cx.scope().builder instanceof InstanceBuilder )
              {
                cx.scope().setInitOnly(true);
              }
             
                node.initializer.evaluate(cx,this);

              if( cx.statics.es4_nullability && cx.scope().builder instanceof InstanceBuilder )
              {
                cx.scope().setInitOnly(false);
              }
            }

      if (node.typeref == null && node.ref != null && node.variable.no_anno)
        warning(node.getPosition(),cx.input, kWarning_NoTypeDecl, "variable", node.ref.name);
     
      Slot type_slot = null;
      if( node.typeref != null && (type_slot = node.typeref.getSlot(cx)) != null )
      {
        checkDeprecatedSlot(cx, node.variable.type, node.typeref, type_slot);
      }
View Full Code Here

    if (!first_pass && node.ref != null)
    {
      Map<TypeValue,Integer> search = unsupportedEventsMap.get(node.ref.name);
      if (search != null && ! search.isEmpty()) // it matches a former auto-registered event handler name
      {
        Slot s = node.ref.getSlot(cx,GET_TOKEN);
        ObjectValue  scope = cx.scope();
        TypeValue  baseType = (scope != null) ? scope.type.getTypeValue() : null;

        if (baseType != null && s != null && !slot_GetRegisteredForEvent(s)) // it wasn't seen in an addEventListener call during first_pass
        {
          for(TypeValue type : search.keySet())
          {
            if (type != null && type.includes(cx,baseType))  // it's defining Type matches one of the warning cases
            {
              int pos = (node.identifier != null) ? node.identifier.getPosition() : node.getPosition();
              warning(pos, cx.input, kWarning_DepricatedEventHandlerError, warningConstantsMap.get(search.get(type)));
            }
          }
        }
        else if (s != null)
        {
          s = null;
        }
      }


    }
    ObjectValue  fun = node.fun;
    cx.pushScope(fun.activation);
    if( node.isFunctionDefinition() == false // if it not a defn then 'this' can be used and is dynamic (i.e. don't warn about undeclared props/methods)
    {
      this_contexts.add(global_this);
    }

    for (int i = 0, size = node.fexprs.size(); i < size; i++)
    {
      FunctionCommonNode item = node.fexprs.get(i);
      item.evaluate(cx,this);
    }

    currentFunctionRef.add(node.ref);

    // set local expected_returnType so that we can check it against what's actually returned in ReturnStatementNode
    boolean is_constructor = "$construct".equals(node.ref.name);
    if (is_constructor)
    {
      this.expected_returnType = cx.voidType();
    }
    else
    {
      this.expected_returnType = node.signature.type!=null?node.signature.type.getTypeValue():cx.noType();
    }

    body_has_return = false;
        if( node.body != null )
    {
      node.body.evaluate(cx,this);
      doing_method = false;
    }
    this.expected_returnType = cx.noType(); // restore to default

    node.signature.evaluate(cx,this);
    currentFunctionRef.removeLast();

    cx.popScope(); // pop activation.  must do this before looking up slot for node.ref, else we can
                       //  bind to the wrong definition in the activation record instead.
        Slot s = node.ref.getSlot(cx,GET_TOKEN);

        if (first_pass && s != null)
        {
            if (body_has_return)
                slot_setHasReturnValue(s,true);
View Full Code Here

  }

  public Value evaluate( Context cx, FunctionSignatureNode node )
  {
    ReferenceValue ref = currentFunctionRef.last();
        Slot s = null;

        if (ref != null)
        {   // must look up the functionRef in the old scope, not the activationObject scope.  Don't want to bind
            //  to like-named arguments!
            ObjectValue oldScope = cx.scope();
View Full Code Here

    if(warningConstantsEN[0] == null) initWarningConstants();
    initialized = true;

    ReferenceValue typeRef;
    Slot s;
    int x;

    // create a unique value to identify a literal 'undefined' with.  We sometimes
    //  need to know when something is being compared against (or assigned) undefined.
    undefinedLiteral = new ObjectValue("", cx.voidType() );

    // lookup TypeValues for built in types we expect
    for(x=0; x < kNumDefaultTypes; x++)
    {
      typeRef = new ReferenceValue(cx, null, typeDescriptors[x].name ,cx.getNamespace(typeDescriptors[x].nameSpace));
      // this getSlot is allowed to bind
      s = typeRef.getSlot(cx,GET_TOKEN);
      // c++ variant accesses union member typValue directly, java stores value in objValue
      TypeValue t = (s != null && s.getObjectValue() instanceof TypeValue) ? (TypeValue)(s.getObjectValue()) : null;
      types[ typeDescriptors[x].code ] = t;
      typeRef = null;
    }

    types[kVoidType] = cx.nullType();
View Full Code Here

    TypeValue functionType = cx.useStaticSemantics() ? cx.functionType() : type;
    int slot_id = super.ExplicitGet(cx,ob,name,namespaces,functionType,true/*is_final*/,false/*is_override*/,expected_id,-1,var_id);
        ob.getSlot(cx, slot_id).setGetter(false);
    int implied_id = ob.addSlotImplicit(cx,slot_id,EMPTY_TOKEN,type)// ISSUE: clean up

    Slot slot = ob.getSlot(cx,implied_id);
    ob.getSlot(cx,implied_id).attrs(CALL_ThisMethod,method_id);
    slot.setFinal(is_final);
    slot.setOverride(is_override);
    slot.setMethodName(classname+"$"+name);
    slot.setGetter(false);
              // this isn't right

    // do backend binding

    if( method_id >= 0 )
View Full Code Here

      if (cx.useStaticSemantics())
      {
        ImplicitCall(cx,ob,slot_id,type,CALL_Method,-1,-1);
        ImplicitConstruct(cx,ob,slot_id,cx.noType(),CALL_Method,-1,-1);

        Slot slot = ob.getSlot(cx,slot_id);
        slot.setConst(true);
        slot.setType(cx.functionType().getDefaultTypeInfo());
      }
    }

        return slot_id;
    }
View Full Code Here

      if (cx.useStaticSemantics())
      {
        ImplicitCall(cx,ob,slot_id,type,CALL_Method,-1,-1);
        ImplicitConstruct(cx,ob,slot_id,cx.noType(),CALL_Method,-1,-1);

        Slot slot = ob.getSlot(cx,slot_id);
        slot.setConst(true);
        slot.setType(cx.functionType().getDefaultTypeInfo());
      }
    }

        return slot_id;
    }
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

TOP

Related Classes of macromedia.asc.semantics.Slot$Overload

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.