Package macromedia.asc.semantics

Examples of macromedia.asc.semantics.Slot


        PreprocessDefinitionTypeInfo(cx,fcn.signature);
        // process local definitions of the function
        if(fcn.body != null)
          PreprocessDefinitionTypeInfo(cx,fcn.body.items);
        cx.popScope();
        Slot slot = fcn.ref.getSlot(cx,fcn.kind);
        if( slot != null )
        {
            slot.setType(fcn.signature.type != null ? fcn.signature.type : cx.noType().getDefaultTypeInfo());
            if( fcn.signature.parameter != null )
            {
                slot.setTypes(fcn.signature.parameter.types);
                slot.setDeclStyles(fcn.signature.parameter.decl_styles);
            }
            else // mark as requiring no arguments for proper # of arg checking
            {
                slot.addType(cx.voidType().getDefaultTypeInfo());        // Use void to denote that no parameters are declared
                slot.addDeclStyle(PARAM_Void);
            }
        }

        if( fcn.def != null && fcn.def.version > -1)
            cx.popVersion();
View Full Code Here


            PreprocessDefinitionTypeInfo(cx,node.instanceinits, false);

        ObjectList<TypeInfo> ctor_types = null;
        ByteList ctor_decls = null;
        // need to look for the constructor and record it's signature.  It needs to be recorded in the class slot, not the function slot
        Slot class_slot = (node.ref != null ?  node.ref.getSlot(cx, NEW_TOKEN) : null);
        if (class_slot != null)
        {
            for (Node init : node.instanceinits)
            {
                if (init instanceof FunctionDefinitionNode)
                {
                    FunctionDefinitionNode func_def = (FunctionDefinitionNode)init;
                    if( func_def.fexpr.ref.name.equals("$construct") )
                    {
                        // Copy the type info from the constructor slot into the global slot that is the reference
                        // to the class - this is so that type checking on constructor calls can happen correctly
                        Slot ctor_slot = func_def.fexpr.ref.getSlot(cx, func_def.fexpr.kind);
                        if (ctor_slot != null)
                        {
                            ctor_types = ctor_slot.getTypes();
                            ctor_decls = ctor_slot.getDeclStyles();
                            class_slot.setTypes(ctor_slot.getTypes());
                            class_slot.setDeclStyles(ctor_slot.getDeclStyles());
                        }
                    }
                }
            }
        }
View Full Code Here

    void PreprocessDefinitionTypeInfo(Context cx, VariableBindingNode  node)
    {
        if( node.typeref != null )
        {
            Slot typeslot = node.typeref.getSlot(cx);
            TypeValue type_val = null;
            TypeInfo type = null;

            if ( typeslot != null && typeslot.getValue() instanceof TypeValue )
            {
                type_val = (TypeValue)(typeslot.getValue());
                type = node.typeref.has_nullable_anno ? type_val.getTypeInfo(node.typeref.is_nullable) : type_val.getDefaultTypeInfo();
            }
            if ( type != null )
            {
                Slot slot = node.ref.getSlot(cx);
                if( slot != null )
                {
                    slot.setType(type);
                    slot.getTypes().clear();
                    slot.getTypes().push_back(type); // cn: issue, this isn't used by SetExpressionNode, just type.  For imported .abc definitions it already contains Object anyway
                }
            }
        }

        if ((node.initializer) instanceof FunctionCommonNode)
View Full Code Here

    }

    public Value evaluate(Context cx, ApplyTypeExprNode node)
    {
        TypeInfo type = cx.noType().getDefaultTypeInfo();
        Slot slot;
        int kind = EMPTY_TOKEN;
        if( node.ref != null )
        {
            Value val = node.expr.evaluate(cx, this);
            node.ref.calcUseDefinitions(cx, rch_bits);
View Full Code Here

     * CallExpression
     */
    public Value evaluate(Context cx, CallExpressionNode node)
    {

        Slot slot = null;
        TypeInfo type = cx.noType().getDefaultTypeInfo();
        int kind = node.is_new ? NEW_TOKEN : EMPTY_TOKEN;
       
        if (node.ref != null)
        {
            /*if (node.ref.getBase() == null)
                            System.out.println("call "+node.ident.name);
                        else
                            System.out.println("call "+node.ref.getBase().type.name+"."+node.ident.name);*/
            node.ref.calcUseDefinitions(cx, rch_bits);

            slot = node.ref.getSlot(cx, kind);
            type = node.ref.getType(cx, kind);
            if( cx.useStaticSemantics() )
            {
                if( slot == null )
                {
                    slot = node.ref.getSlot(cx, GET_TOKEN);
                    // check for function/Class valued properties and getter functions which return functions/Classes
                    if (slot != null)
                    {
                        TypeValue t = slot.getType() != null ? slot.getType().getTypeValue() : null;
                        // note: you can call a Class valued var, it acts like an explicit cast
                        if ( t != cx.typeType() && t != cx.functionType() && t != cx.objectType() && t != cx.noType())
                        {
                            slot = null;
                            // don't permanently bind to the get slot.
                            node.ref.slot = null;
                        }
                    }

                    if (slot == null)
                    {
                        ObjectValue base = node.ref.getBase();
                        if( base == null )
                        {
                            if( cx.statics.withDepth == -1 ) cx.error(node.pos(), kError_Strict_PlainUndefinedMethod,node.ref.name);
                        }
                        //  Note: Function is dynamic, but methods of a class are MethodClosures, a non-dynamic subclass of Function.
                        //  The compiler doesn't have an internal representation of MethodClosure, though the only reason it would
                        //  need one is for this check.  Rather than modify a lot of existing compiler code to check type.memberOf(cx.functionType())
                        //  instead of type == cx.functionType() (and likely some other less obviuos dependances), we're just going to check
                        //  the builder here to distinguish between a global function and a non-global function.
                        else if (!base.isDynamic() || (base.getType(cx).getTypeValue() == cx.functionType() && !(base.builder instanceof GlobalBuilder)) )
                        {
              if ( (base instanceof TypeValue) || (base.type != null && base.type.getTypeValue() != cx.noType()) )
              {
                String className = (base instanceof TypeValue) ? "Class" : base.getType(cx).getName(cx).toString();

                if (base.hasNameUnqualified(cx, node.ref.name, GET_TOKEN))
                  cx.error(node.pos(), kError_InaccessibleMethodReference, node.ref.name, className);
                else
                  cx.error(node.pos(), kError_Strict_UndefinedMethod, node.ref.name, className);
              }
                        }
                    }
                    if (slot != null)
                    {
                        // don't permanently bind to the get slot.
                        node.ref.slot = null;
                        slot = null;
                    }
                }
            }
            if( slot == null && node.is_new)
            {
                Slot callSlot = node.ref.getSlot(cx,EMPTY_TOKEN);
                Slot getSlot  = node.ref.getSlot(cx,GET_TOKEN);
                if ( callSlot != null && getSlot != null && getSlot.declaredBy != null &&
                     ((getSlot.declaredBy.builder instanceof ClassBuilder) || (getSlot.declaredBy.builder instanceof InstanceBuilder)) )
                {
                    cx.error(node.pos(), kError_MethodIsNotAConstructor);
                }
            }
            type = type != null ? type : cx.noType().getDefaultTypeInfo();
            if (node.is_new && slot != null && slot.getType() != null)
            {
                    Builder bui = slot.getType().getBuilder();
                    if (bui instanceof ClassBuilder && ((ClassBuilder)bui).is_interface)
                    {
                        cx.error(node.pos(), kError_CannotInstantiateInterface);
                    }
            }
        }
        else
        {
            node.expr.evaluate(cx, this);
        }

        boolean callOfClass = false;
        if ( !node.is_new && node.ref != null )
        {
            Slot newSlot = node.ref.getSlot(cx, NEW_TOKEN);
            if (newSlot != null && newSlot.getType() != null && newSlot.getType().getTypeValue() != cx.noType()) // cn: in !, global Functions have new slots.  Only classes have non-object types for their new slot
                callOfClass = true;
        }

        if (callOfClass)
        {
View Full Code Here

        return type.getPrototype();
    }

    public Value evaluate(Context cx, InvokeNode node)
    {
        Slot slot = null;
        TypeValue type;

        if ("[[HasMoreNames]]".equals(node.name))
        {
            node.index = UNARY_HasMoreNames;
            node.args.addType(cx.intType().getDefaultTypeInfo());
            type = cx.intType();
        }
        else if ("[[NextValue]]".equals(node.name))
        {
            node.index = UNARY_NextValue;
            node.args.addType(cx.intType().getDefaultTypeInfo());
            type = cx.noType();
        }
        else if ("[[NextName]]".equals(node.name))
        {
            node.index = UNARY_NextName;
            node.args.addType(cx.intType().getDefaultTypeInfo());
            type = cx.stringType();
        }
        else if ("[[ToXMLString]]".equals(node.name))
        {
            node.index = UNARY_ToXMLString;
            node.args.addType(cx.noType().getDefaultTypeInfo());
            type = cx.stringType();
        }
        else if ("[[ToXMLAttrString]]".equals(node.name))
        {
            node.index = UNARY_ToXMLAttrString;
            node.args.addType(cx.noType().getDefaultTypeInfo());
            type = cx.stringType();
        }
        else if ("[[CheckFilterOperand]]".equals(node.name))
        {
            node.index = UNARY_CheckFilterOp;
            node.args.addType(cx.noType().getDefaultTypeInfo());
            type = cx.noType();
        }
        else
        {
            assert(false); // throw "should not get here";
            type = cx.noType();
        }

        if (node.args != null)
        {
            if (slot != null)
            {
                node.args.expected_types = slot.getTypes();
            }
            node.args.evaluate(cx, this);
        }

        return type.prototype;
View Full Code Here

        if (node.ref != null)
        {
            node.ref.calcUseDefinitions(cx, rch_bits);
            if( cx.useStaticSemantics() ) // bang
            {
                Slot slot = node.ref.getSlot(cx,GET_TOKEN);
                if( slot == null )
                {
                    ObjectValue base = node.ref.getBase();
                    //  Note: only global Functions are dynamic, but methods of a class are MethodClosures, a non-dynamic subclass of Function.
                    if( base != null && (!base.isDynamic() || (base.getType(cx).getTypeValue() == cx.functionType() && !(base.builder instanceof GlobalBuilder)) ) )
                    {
                        if (base.hasNameUnqualified(cx, node.ref.name, GET_TOKEN))
                            cx.error(node.expr.pos(), kError_InaccessiblePropertyReference, node.ref.name, base.getType(cx).getName(cx).toString());
                        else
                            cx.error(node.expr.pos(), kError_UndefinedProperty,node.ref.name,base.getType(cx).getName(cx).toString());
                    }
                }

                ObjectValue base = node.ref.getBase();
                boolean isDynamic = base != null && base.isDynamic();

                if( slot != null && !in_with && !isDynamic )
                {
                    cx.error(node.expr.pos(), kError_Strict_AttemptToDeleteFixedProperty, node.ref.name);
                }

            }
        }
        else
        {
            // If its not a reference, then evaluate it.
            node.expr.evaluate(cx, this);
        }

        Slot slot;

        {
            ObjectValue global;
            global = cx.builtinScope();
            slot = global.getSlot(cx, SLOT_Global_DeleteOp);

            // Now we know the type expected by the unary operator. Coerce it.
            //node.expr = cx.coerce(node.expr,type,slot.types.size()?slot.types[0]:cx.noType());

            // Save the slot index in the node for later use
            // by the code generator.
            node.slot = slot;
        }

        return slot.getType().getPrototype();
    }
View Full Code Here

            node.ref.calcUseDefinitions(cx, rch_bits);


            if (node.ref.usedBeforeInitialized())
            {
                Slot s = node.ref.getSlot(cx,GET_TOKEN);
                if (s != null)
                    s.setNeedsInit(true);
            }


            val = node.ref;
            node.ref.getType(cx,GET_TOKEN);
            if( cx.useStaticSemantics() ) // bang
            {
                Slot slot = node.ref.getSlot(cx,GET_TOKEN);
                if( slot == null )
                {
                    ObjectValue base = node.ref.getBase();
                    //  Note: only global Functions are dynamic, but methods of a class are MethodClosures, a non-dynamic subclass of Function.
                    if( base != null && (!base.isDynamic() || (base.getType(cx).getTypeValue() == cx.functionType() && !(base.builder instanceof GlobalBuilder)) ) )
View Full Code Here

                    //   var x : String = "hi";
                    //
                    // We need to init this at the top of the method, otherwise the types for
                    // x at the end of the if block would be * and String, which wouldn't match
                    // and would cause a verify error.
                      Slot s = node.ref.getSlot(cx,GET_TOKEN);
                      if (s != null)
                          s.setNeedsInit(true);
                  }
              }
             
                Slot slot = node.ref.getSlot(cx,SET_TOKEN);

                node.ref.getType(cx,SET_TOKEN);

                if( slot != null )
                {
                    // need to check var_index to see if this is a setter.  In the case of slots inherited during abc import,
                    //  this will only be accurate for the original slot
                    Slot origSlot = slot;

                    if( origSlot.getVarIndex() < 0 && size(slot.getTypes()) == 1 )
                    {
                        node.args.addType(slot.getTypes().get(0)); // setter, expected type is param type
                    }
                    else
                    {
                        node.args.addType(slot.getType());
                    }
                }
                else
                {
                    node.args.addType(cx.noType().getDefaultTypeInfo());
                }

              
            }
            else if( node.base != null && node.getMode()==LEFTBRACKET_TOKEN )
            {
                node.expr.evaluate(cx, this);
                TypeInfo t = cx.noType().getDefaultTypeInfo();
                if( node.base.type != null )
                {
                    TypeValue tv = node.base.type.getTypeValue();
                    t = tv.indexed_type != null ? tv.indexed_type.getDefaultTypeInfo() : cx.noType().getDefaultTypeInfo();
                }
                node.args.addType(t);
            }
            else
            {
                node.expr.evaluate(cx, this); // Only do this if there is no ref.
                node.args.addType(cx.noType().getDefaultTypeInfo());
            }
        }

//        rch_bits = rch_bits & ~ node.gen_bits;   // temporarily turn off the current gen bits

        Value val = node.args.evaluate(cx, this);
        TypeInfo type = val != null ? val.getType(cx) : cx.noType().getDefaultTypeInfo();

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

            int rchkill_bits_count = BitSet.and_count(rch_bits, node.getKillBits())// number of kill bits that reach this definition, should be zero
            int scope_index = node.ref.getScopeIndex(GET_TOKEN);
            int base_index = cx.getScopes().size()-1;

            if (slot != null && slot.isConst() && slot.getType().getTypeValue() == cx.typeType())
            {
                Node firstArg = node.args.items.get(0);
                // check if its the synthetic assignment invented for a CDN.  Authors can't assing a var directly to a CDN
                if (!(firstArg instanceof ClassDefinitionNode))
                {
                    if (slot.getObjectValue() != null) // slot will only have a value if this is a class slot
                    {
                        cx.error(node.pos(), kError_AssignmentToDefinedClass, node.ref.name);
                    }
                }
            }
            else if (slot != null && slot.isConst() && slot.getType().getTypeValue() == cx.functionType())
            {
                Node firstArg = node.args.items.get(0);

                // check if its the synthetic assignment invented for a FDN.
                if (!(firstArg instanceof FunctionCommonNode && ((FunctionCommonNode)firstArg).def != null) )
                {
                    // if the base type is XML or XMLList, ignore.  The prop may actually evaluate to a non-function at runtime (for instance, .name)
                    boolean isXMLProp = false;
                    ObjectValue base = node.ref.getBase();
                    if (base != null &&
                       (base.getType(cx).getTypeValue() == cx.xmlType() ||
                        base.getType(cx).getTypeValue() == cx.xmlListType()))
                    {
                            isXMLProp = true;
                    }
                    if (!isXMLProp && slot.getObjectValue() != null)
                    {
                        cx.error(node.pos(), kError_AssignmentToDefinedFunction, node.ref.name);
                    }
                }
            }
            else if( slot != null && slot.isConst() && (slot.isImported() || scope_index != base_index || val.hasValue() || rchkill_bits_count > 0) )
            {
                cx.error(node.pos(), kError_AssignmentToConstVar);
            }
            else if( cx.useStaticSemantics() && slot == null )
            {
                // If there is no set but there is a get, then the property is read only. Post an error.
                slot = node.ref.getSlot(cx,GET_TOKEN);
                if ( slot != null )
                {
                    // slot will only have a value if this is a slot for a non-anonymous function
                    if( slot.getType() != null && slot.getType().getTypeValue() == cx.functionType() && slot.getObjectValue() != null )
                    {
                        Node firstArg = node.args.items.get(0);
                        CoerceNode cn = (firstArg instanceof CoerceNode) ? (CoerceNode)firstArg : null;
                        if ( !firstArg.isSynthetic() || (cn != null && !(cn.expr instanceof FunctionCommonNode) ) ) // its not the synthetic assignment invented for a FDN.  Authors can't assing a var directly to a FCN
                        {
View Full Code Here

    }

    private static Variable getVariable(Context cx, AbcClass watchedClass, ReferenceValue ref, MultiName multiName)
    {
        Variable var = null;
        Slot s;
        if( ref != null )
        {
            // if ref.slot is non-null then the reference has already been resolved.
            if( ref.slot != null && ref.getKind() == Tokens.GET_TOKEN)
            {
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.