Package macromedia.asc.semantics

Examples of macromedia.asc.semantics.Slot


  {
    TypeValue functionType = cx.useStaticSemantics() ? cx.functionType() : type;
    int slot_id = ob.addMethodSlot(cx,functionType);
    CHECK_SLOT_INDEX(expected_id,slot_id);
    ob.defineNames(cx,GET_TOKEN,name,namespaces,slot_id);
    Slot slot = ob.getSlot(cx,slot_id);
    ob.getSlot(cx,slot_id).attrs(CALL_ThisMethod,method_id);
    slot.setFinal(is_final);
    slot.setOverride(is_override);
    slot.setGetter(false);

    // do backend binding

    if( method_id >= 0 )
    {
View Full Code Here


            {
              // new way
              int slot_id = objectValue.getSlotIndex(cx, GET_TOKEN, name, ns);
              if(slot_id > 0)
              {
                Slot s = objectValue.getSlot(cx, slot_id);
                if(s.getMethodID() != -1 && s.declaredBy == objectValue)
                {
                  return s.getMethodID();
                }
              }
            }
          }
        }
View Full Code Here

        int base_index = node.ref != null ? node.ref.getScopeIndex(node.ref.getKind()) : -1;

        // This is an alias to node.<selector>.ref, so the
        // evaluator for node.<selector> has access to the
        // same info
        Slot slot = node.ref != null ? node.ref.getSlot(cx, node.selector instanceof SetExpressionNode ? SET_TOKEN : GET_TOKEN) : null;

        int scope_depth = cx.getScopes().size() - 1;

        if (node.base != null)
        {
            boolean old_in_typeof = this.in_typeof;
            this.in_typeof = false// typeof requires a non-strict FindProperty mode for the leaf property, but not for any  base properties

            // If there is a base expression: evaluate it,
            // get its value, and convert it to an object.
            node.base.evaluate(cx, this);
            node.selector.setSuper((node.base instanceof SuperExpressionNode));
            node.selector.setThis((node.base instanceof ThisExpressionNode));
            if (node.ref != null)      
            {
                node.ref.setScopeIndex(-2)// -2 means there is a base reference
            }
            this.in_typeof = old_in_typeof;
        }
        else
        if (slot != null && isClassInitializerReference(cx, slot.getValue()))
        {
            // Special case for $cinit functions that reference the class
            // being initialized.  See bug #113887.
        }
        else if( base_index == 0 && (node.selector.isCallExpression() || node.selector.isApplyTypeExpression()))
View Full Code Here

        boolean is_super = node.isSuper();
        boolean is_qualified = node.isQualified();
        boolean is_attribute = node.isAttributeIdentifier();

        Slot slot;
        TypeInfo expr_type=null;
        int  base_index=-1;
        int  scope_depth = cx.getScopes().size()-1;

        Builder basebui;

        boolean is_localref = false;


        if( node.ref == null )
        {
            if (node.is_new)
            {
                call_seq  = CALL_EnvThisArgs;
                disp_kind = DISP_ConstructClosure;
                this_kind = THIS_None;
            }
            else
            if( node.isRvalue() )
            {
                call_seq  = CALL_EnvThisArgs;
                disp_kind = DISP_CallClosure;
                this_kind = THIS_Global;
            }
            else
            {
                call_seq  = CALL_EnvThisArgs;
                disp_kind = DISP_CallClosure;
                this_kind = THIS_Base;
            }
        }
        else
        {
            slot                 = node.ref.getSlot(cx,GET_TOKEN);
            expr_type            = node.ref.getType(cx);
            base_index           = node.ref.getScopeIndex(GET_TOKEN);

            basebui              = base_index >= 0 ? cx.scope(base_index).builder : null;

            boolean is_outerfunc;

            boolean is_globalref;
            boolean is_dotref;
            boolean is_cinit_ref;

            is_localref          = isLocalScope(cx, base_index);
            is_outerfunc         = base_index != 0 && base_index <  frame.firstInnerScope && basebui instanceof ActivationBuilder;
            is_globalref         = base_index == 0;
            is_dotref            = base_index == -2;
            boolean is_lexref    = !(is_localref || is_dotref);
            is_cinit_ref         = slot != null && isClassInitializerReference(cx, slot.getValue());

            if (is_cinit_ref)
            {
                 // Special case for $cinit functions that reference the class
                // being initialized.  See bug #113887.
                LoadThis();

                call_seq = CALL_Args;
                disp_kind = node.is_new ? DISP_ConstructClosure : DISP_CallClosure;
                this_kind = node.is_new ? THIS_None : THIS_Scope;
            }
            else
            if( is_localref )
            {
                call_seq  = CALL_EnvThisArgs;
                disp_kind = DISP_CallClosure;
                this_kind = THIS_Global;
            }
            else
            if( is_globalref // some of these can be turned into CallFinal
            {
            //#if 1 // when OP_constructproperty is supported
                call_seq  = CALL_Args;
                disp_kind = node.is_new?DISP_ConstructProperty:DISP_CallProperty;
                this_kind = node.is_new?THIS_None:THIS_Base;
            //#else
            //                    call_seq  = CALL_EnvThisArgs;
            //                    disp_kind = DISP_CallClosure;
            //                    this_kind = THIS_Base;
            //#endif
            }
            else
            if( is_dotref )
            {
                call_seq  = CALL_Args;
                disp_kind = node.is_new?DISP_ConstructProperty:DISP_CallProperty;
                this_kind = node.is_new?THIS_None:THIS_Base;
            }
            else
            if( is_lexref // some of these can be turned into CallFinal
            {
                if( is_outerfunc )
                {
            //#if 1 // when OP_callproplex is supported
                    call_seq  = CALL_Args;
                    disp_kind = node.is_new?DISP_ConstructProperty:DISP_CallPropLex;
                    this_kind = node.is_new?THIS_None:THIS_Base;
            //#else
            //                    call_seq  = CALL_EnvThisArgs;
            //                    disp_kind = DISP_CallClosure;
            //                    this_kind = THIS_Global;
            //#endif
                }
                else
                {
            //#if 1 // when OP_constructproperty is supported
                    call_seq  = CALL_Args;
                    disp_kind = node.is_new?DISP_ConstructProperty:DISP_CallProperty;
                    this_kind = node.is_new?THIS_None:THIS_Base;
            //#else
            //                    call_seq  = CALL_EnvThisArgs;
            //                    disp_kind = DISP_CallClosure;
            //                    this_kind = node.is_new?THIS_None:THIS_Base;
            //#endif
                }
            }
            else
            {
                cx.internalError("missing call case");
            }

            // if it is monomorphic and lexical and in an inner scope, then call final

            Slot method_slot = node.ref.getSlot(cx,slot_kind);
            if( base_index > 0 && method_slot != null )
            {
                // Has an implied method (call or construct), so use it. For now,
                // we just do this for functions, we could do it for inherited
                // methods where the implementing class is defined in the current
                // script.

                if( is_outerfunc && !in_with && method_slot.getMethodID() >= 0 )
                {
                    call_seq  = method_slot.getCallSequence();
                    method_name = method_slot.getMethodName();
                    disp_kind = DISP_CallFinal; //method_slot.dispatch_kind;
                    this_kind = THIS_Global; // is_dotref?THIS_Base:is_outerfunc?THIS_Global:THIS_Base;
                }
            }
View Full Code Here

                freeTemp(temp_val_reg); // temp_val_reg
            }
        }
        else
        {
            Slot slot                = node.ref.getSlot(cx,SET_TOKEN);
            TypeInfo expr_type       = node.ref.getType(cx);
            int  base_index          = node.ref.getScopeIndex(SET_TOKEN);
            int  slot_index          = node.ref.getSlotIndex(SET_TOKEN);
            int  scope_depth         = cx.getScopes().size()-1;
           
            int reg_offset = getRegisterOffset(cx);
            int var_offset = cx.scope(scope_depth).builder.var_offset;

            Builder bui                  = base_index>0?cx.scope(base_index).builder:null; // get the builder from lexical scope, null if object reference

            boolean is_constinit         = node.is_constinit?true:(is_ctor&&node.isThis())?true:(bui instanceof InstanceBuilder)?true:false;
            boolean is_const             = slot!=null?slot.isConst():false;

            boolean is_localref          = isLocalScope(cx, base_index);
            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( is_unbound_ref )
            {
                // If it is a global ref, then the base object is not yet on the
                // stack. Push it now

                if( is_globalref )
                {
                    GetGlobalScope();
                }

                // Push the value on the stack

                node.args.evaluate(cx,this);

                // See if we can tell if the reference is dynamic or not.
                // This is only possible when it is a dot reference, but
                // we don't worry about that here, to simplify

/*  runtime error
                ObjectValue bobj = node.ref.getBase();
                TypeValue btyp = bobj != null ? bobj.getType(cx) : cx.noType();

                if (btyp.isFinal() && !btyp.isDynamic())
                {
                    cx.error(node.pos(), kError_UnknownPropertyInNonDynamicInstance, node.ref.name);
                }
*/
                {
                    if (!node.void_result)
                    {
                        Dup();
                        temp_val_reg = allocateTemp();
                        StoreRegister(reg_offset+temp_val_reg, expr_type.getTypeId());
                    }
                    SetProperty(node.ref.name, node.ref.getImmutableNamespaces(), node.ref.isQualified(), is_super, is_attribute, is_constinit);
                }

                if (!node.void_result)
                {
                    LoadRegister(reg_offset+temp_val_reg, expr_type.getTypeId());
                    freeTemp(temp_val_reg)// temp_val_reg
                }
            }
            else if (is_globalref)
            {
                // Found, global variable
                int varIndex = slot.getVarIndex();
                if (slot.declaredBy != cx.scope(0))
                {
                    varIndex = -1;
                }

                if (slot.getMethodID() >= 0 || varIndex < 0) // Need to put global on stack
                {
                    FindProperty(node.ref.name,node.ref.getImmutableNamespaces(),node.ref.isQualified(),is_super,is_attribute);
                }
                else
                if( is_const )
                {
                    GetBaseObject(0);
                }

                // Push the value

                node.args.evaluate(cx,this);

                if( !node.void_result )
                {
                    Dup();
                    temp_val_reg = allocateTemp();
                    StoreRegister(reg_offset+temp_val_reg,expr_type.getTypeId());
                }
  
                if( slot.getMethodID() >= && cx.globalScope() == slot.declaredBy) // If it is a setter, invoke it.
                {
                    InvokeMethod(false/*is_virtual*/,GetMethodInfo(slot.getMethodName()), 1);
                   
                    //  callstatic's semantics leave a value on the stack; a void setter
                    //  doesn't return anything, so pop this pseudo return value to keep
                    //  the stack balanced.
                    if ( node.void_result )
                      Pop();
                }
                else // If it is a variable and we know the index, then store it
                if( varIndex >= 0 && !is_const)
                {
                    StoreGlobal(varIndex,expr_type.getTypeId());
                }
                else // Otherwise, just do a generic store global by name
                {
                    SetProperty(node.ref.name, node.ref.getImmutableNamespaces(), node.ref.isQualified(), is_super, is_attribute, is_constinit);
                }

                if( !node.void_result )
                {
                    LoadRegister(reg_offset+temp_val_reg,expr_type.getTypeId());
                    freeTemp(temp_val_reg)// temp_val_reg
                }
            }
            else if (is_localref)
            {
                // Found, local variable

                {
                    if( is_const && !is_constinit )
                    {
                        PushString("Illegal write to local const " + node.ref.name);
                        Throw();
                    }

                    if( slot.getMethodID() >= 0 || frame.registerScopeIndex != base_index)
                    {
                        GetActivationObject(base_index);
                    }
                    node.args.evaluate(cx,this);
                    if (!node.void_result)
                    {
                        Dup();
                        temp_val_reg = allocateTemp();
                        StoreRegister(reg_offset+temp_val_reg, expr_type.getTypeId());
                    }

                    if( slot.getMethodID() >= 0 )
                    {
                        InvokeMethod(true,slot.getMethodID(),1);
                    }
                    else
                    {
                        // issue this CheckType is too conservative
                        // explicit coerce before setting a local, in case VM doesn't know
                        // the type that we know here. (e.g. calling through an interface)
                        CheckType(slot.getType().getName(cx));
                        if (frame.registerScopeIndex != base_index)
                        {
                                StoreVar(var_offset+slot.getVarIndex());
                        }
                        else
                        {
                            //CheckType(slot.getType().name);
                            StoreRegister(reg_offset+slot.getVarIndex(),expr_type.getTypeId(),node.ref.name);
                        }
                    }

                    if (!node.void_result)
                    {
View Full Code Here

                Pop();
            }
        }
        else
        {
            Slot slot                = node.ref.getSlot(cx,GET_TOKEN);
            TypeInfo expr_type      = node.ref.getType(cx);
            int  base_index           = node.ref.getScopeIndex(GET_TOKEN);
            int  slot_index           = node.ref.getSlotIndex(GET_TOKEN);
            int  scope_depth          = cx.getScopes().size()-1;

            Builder basebui = base_index >= 0 ? cx.scope(base_index).builder : null;
            boolean is_localref          = isLocalScope(cx, base_index);
            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( is_unbound_ref )
            {
                // The slot was not found.

                if( node.ref.getSlot(cx,SET_TOKEN) != null )
                {
                    cx.error(node.pos(), kError_PropertyIsWriteOnly);
                }

                // If the base_index is 0 then push the base object
                if( is_globalref )
                {
                    GetGlobalScope();
                }

                /* should be runtime error
                ObjectValue bobj = node.ref.getBase();

                if( btyp.isFinal() && !btyp.isDynamic())
                {
                    cx.error(node.pos() - 1, kError_UnknownPropertyInNonDynamicInstance, node.ref.name);
                }
*/
                {
                    // Otherwise, we don't know the base or the slot, so just do a general
                    // property ref.
                    GetProperty(node.ref.name,node.ref.getImmutableNamespaces(),node.ref.isQualified(),is_super,is_attribute);
                }
                if (node.isVoidResult())
                {
                    Pop();
                }
            }
            else if (is_globalref)
            {
                // Found. It's a global. To bind to var indexes at compile-time
                // the var index has to be owned by the base object, not one of
                // its prototypes.

                // Fixed global
                slot = node.ref.getSlot(cx, GET_TOKEN);
                if (slot.getMethodID() >= 0 && cx.globalScope() == slot.declaredBy) // If it is a method, invoke it.
                {
                    // The property has a global getter and is defined in the same source file, just
                    // invoke the method directly.
                    GetGlobalScope();
                    InvokeMethod(false, GetMethodInfo(slot.getMethodName()), 0);
                    if (node.isVoidResult())
                    {
                        Pop();
                    }
                }
                else if (slot.getValue() == cx.scope(scope_depth))
                {
                    // Special case for $cinit functions that reference the class
                    // being initialized.  See bug #113887.
                    LoadThis();
                }
                else // If it is a variable, then load it.
                {
                    if (!node.isVoidResult())
                    {
                        int varIndex = slot.getVarIndex();
                        if (slot.declaredBy != cx.scope(0))
                        {
                            varIndex = -1;
                        }
                        if (varIndex >= 0)
                        {
                            LoadGlobal(varIndex, expr_type.getTypeId());
                        }
                        else
                        {
                            // imported slot
                            FindProperty(node.ref.name,node.ref.getImmutableNamespaces(), true/*is_strict*/, node.ref.isQualified(), is_attribute);
                            GetProperty(node.ref.name,node.ref.getImmutableNamespaces(),node.ref.isQualified(), is_super, is_attribute);
                            //cx.internalError("Internal error: don't know how to get global property",node->pos()-1);
                        }
                    }
                }
            }
            else if (is_localref)
            {
                int reg_offset = getRegisterOffset(cx);
                int  var_offset = cx.scope(scope_depth).builder.var_offset;

                // Found. It's a local
                if( slot.getMethodID() >= 0 )
                {
                    GetActivationObject(base_index);
                    GetProperty(node.ref.name,node.ref.getImmutableNamespaces(),node.ref.isQualified(),is_super,is_attribute);
                    if( node.isVoidResult() )
                    {
                        Pop();
                    }
                }
                else
                if (!node.isVoidResult())
                {
                    if (frame.registerScopeIndex != base_index)
                    {
                        GetActivationObject(base_index);
                        LoadVar(var_offset+slot.getVarIndex());
                    }
                    else
                    {
                        LoadRegister(reg_offset+slot.getVarIndex(), expr_type.getTypeId());
                    }
                }
            }
            else
            {
View Full Code Here

            }
        }
        else
        {
            // Member expression
            Slot slot = node.ref.getSlot(cx);
            type = node.ref.getType(cx);

            // If we are calling the int version of increment/decrement then there is no point in calling
            // ToNumber on the operand, since we know that we are incrementing an int.  The ToNumber is unneccesary, and we'll
            // undo it anyways in increment_i/decrement_i which will cast down to an int.
            int method_id = node.slot.getMethodID();
            boolean already_int = method_id == UNARY_IncrementOp_I ||
                                  method_id == UNARY_IncrementLocalOp_I ||
                                  method_id == UNARY_DecrementOp_I ||
                                  method_id == UNARY_IncrementLocalOp_I;

            int base_index = node.ref.getScopeIndex(GET_TOKEN);
            int slot_index = node.ref.getSlotIndex(GET_TOKEN);
            if (slot_index < 0 || base_index < 0)
            {
                // Dynamic reference
                if (base_index == 0)
                {
                    GetGlobalScope();
                }
                Dup();
                StoreRegister(reg_offset+temp_base_reg.get(), TYPE_none);
                GetProperty(node.ref.name,node.ref.getImmutableNamespaces(), node.ref.isQualified(), is_super, is_attribute);
                if (node.isPostfix && !node.void_result)
                {
                    // Postfix result
                    if( !already_int )
                        ToDouble(TYPE_double); // ES3 11.3.2 step 6
                    Dup();
                }
            }
            else if (base_index == 0)
            { // found slot, invoke it
                // Fixed global
                LoadGlobal(slot.getVarIndex(), type.getTypeId());
                if (node.isPostfix && !node.void_result)
                {
                    // Postfix result
                    if( !already_int )
                        ToDouble(TYPE_double); // ES3 11.3.2 step 6
                    Dup();
                }
            }
            else if (isLocalScope(cx, base_index))
            {
                reg = node.ref.getSlot(cx, GET_TOKEN).getVarIndex();
                // Postfix result
                if (frame.registerScopeIndex != base_index)
                {
                    GetActivationObject(base_index);
                    LoadVar(var_offset+node.ref.getSlot(cx, GET_TOKEN).getVarIndex());
                }
                else
                {
                    LoadRegister(reg_offset+node.ref.getSlot(cx, GET_TOKEN).getVarIndex(), type.getTypeId());
                }
                if (node.isPostfix && !node.void_result)
                {
                    // Postfix result
                    if( !already_int )
                        ToDouble(TYPE_double); // ES3 11.3.2 step 6
                    Dup();
                }
            }
            else
            {
                // Fixed property
                Dup();
                StoreRegister(reg_offset+temp_base_reg.get(), TYPE_none);
                Value val = node.ref.getBase();
                ObjectValue base = (val instanceof ObjectValue) ? (ObjectValue) val : null;
                base = base != null ? base : cx.scope(node.ref.getScopeIndex());
                GetProperty(node.ref.name,node.ref.getImmutableNamespaces(), node.ref.isQualified(), is_super, is_attribute);
                if (node.isPostfix && !node.void_result)
                {
                    // Postfix result
                    if( !already_int )
                        ToDouble(TYPE_double); // ES3 11.3.2 step 6
                    Dup();
                }

            }
        }

        // Increment the value

        InvokeUnary(node.slot.getMethodID(), 0, reg_offset+reg, used_namespaces_sets.back(), node.numberUsage);

        // Put the new value back

        if (node.ref == null)
        {
            if (!node.isPostfix && !node.void_result)
            {
                // Prefix result
                Dup();
            }

            // Save incremented value it in a temp
            StoreRegister(reg_offset+temp_val_reg.get(), type.getTypeId());

            // Indexed member expression
            LoadRegister(reg_offset+temp_base_reg.get(), TYPE_none);    // Base object
            LoadRegister(reg_offset+temp_name_reg.get(), TYPE_none);
            LoadRegister(reg_offset+temp_val_reg.get(), TYPE_none);        // Value
            InvokeUnary(UNARY_Put, 1, -1, used_namespaces_sets.back(), node.numberUsage);
        }
        else
        {
            // Member expression
            Slot slot = node.ref.getSlot(cx);
            int base_index = node.ref.getScopeIndex(SET_TOKEN);
            int slot_index = node.ref.getSlotIndex(SET_TOKEN);
            if (slot_index < 0 || base_index < 0)
            {
                if (!node.isPostfix && !node.void_result)
                {
                    // Prefix result
                    Dup();
                }

                // Save incremented value it in a temp
                StoreRegister(reg_offset+temp_val_reg.get(), type.getTypeId());

                // Dynamic reference
                LoadRegister(reg_offset+temp_base_reg.get(), TYPE_none);
                LoadRegister(reg_offset+temp_val_reg.get(), TYPE_none);
                SetProperty(node.ref.name,node.ref.getImmutableNamespaces(),node.ref.isQualified(), is_super, is_attribute, false);
            }
            else if (base_index == 0)
            {
                if (!node.isPostfix && !node.void_result)
                {
                    // Prefix result
                    Dup();
                }

                // Save incremented value it in a temp
                StoreRegister(reg_offset+temp_val_reg.get(), type.getTypeId());

                // Fixed global
                PreStoreGlobal(slot.getVarIndex(), type.getTypeId())// swf only
                LoadRegister(reg_offset+temp_val_reg.get(), type.getTypeId());
//                CheckType(slot.type.name);
                StoreGlobal(slot.getVarIndex(), type.getTypeId());
            }
            else if (isLocalScope(cx, base_index))
            {
                if (!node.isPostfix && !node.void_result)
                {
View Full Code Here

        // get scope relative offsets
        ObjectValue obj = node.activation;
        Builder bui = obj.builder;
        int var_offset = bui.var_offset;

        Slot slot = null;
        TypeInfo type = null;
        QName qname = null;

        cx.pushScope(node.activation);

        if (node.parameter instanceof ParameterNode)
        {
            // get param info
            ParameterNode parameter = (ParameterNode) node.parameter;
            slot = parameter.ref.getSlot(cx, GET_TOKEN);
            type = slot.getType();

            qname = new QName(cx.publicNamespace(), parameter.ref.name);
        } else
        {
            type = cx.noType().getDefaultTypeInfo();
        }

        Catch(type.getTypeValue(), qname);

        // Restore "this" if in a method that uses this
        if (frame.withThis)
        {
            LoadThis();
            PushScope();
        }

        // Restore scopes
        for (int i = frame.firstInnerScope, n = cx.getScopes().size(); i < n; i++)
        {
            Builder builder = cx.scope(i).builder;
            int temp_reg = builder.temp_reg;
            if (temp_reg != -1)
            {
                LoadRegister(temp_reg + reg_offset, TYPE_none);
                if (builder instanceof WithBuilder)
                {
                    PushWith();
                } else
                {
                    PushScope();
                }
            }
        }

        int temp_activation_reg = -1;

        // Generate code to push the exception scope's activation object
        NewCatch(frame.catchIndex);
        Dup();

        // Store the catch activation object
        temp_activation_reg = allocateTemp();
        node.activation.builder.temp_reg = temp_activation_reg;
        StoreRegister(reg_offset + temp_activation_reg, TYPE_none);

        if (qname != null)
        {
            Dup();
        }

        PushScope();

        if (qname != null)
        {
            // Store the exception variable
            Swap();
            StoreVar(slot.getVarIndex() + var_offset);
        }

        frame.catchIndex++;

        if (node.statements != null)
View Full Code Here

        {
            VariableBindingNode binding = it instanceof VariableBindingNode ? (VariableBindingNode)it : null;
            if (binding != null)
            {
                ReferenceValue ref;
                Slot slot;
                if ( (ref = binding.ref) == null)
                    ; // no good
                else if ( (slot = ref.getSlot(cx)) == null )
                    ; // no good
                else if (slot.getVarIndex() < 0)
                    ; // no good
                else
                {
                    boolean onActivationObject   = frame.activationIsExposed;
                    TypeInfo expr_type      = binding.ref.getType(cx);
                    int  base_index           = binding.ref.getScopeIndex(GET_TOKEN);

                    Builder basebui          = base_index >= 0 ? cx.scope(base_index).builder : null;
                    boolean is_globalref         = base_index == 0;

                    boolean isInheritedSlot = (slot.declaredBy != cx.scope(base_index));

                    // If we're doing the constructor, don't call DefineSlotVariable for the instance inits because they
                    // are slots on the instance, and they could end up overwriting arguments/locals in the constructor body
                    boolean isInstanceInit = basebui instanceof InstanceBuilder && cx.scope().builder instanceof ActivationBuilder;

                    if (!is_globalref && !isInheritedSlot && !onActivationObject && !isInstanceInit)
                    {
                        if (basebui != null)
                        {
                            //int reg_offset = basebui.reg_offset;
                            //setOrigin(cx.input.source());
                            if (cx.input != null)
                            {
                                setPosition(cx.input.getLnNum(binding.pos()),
                                            cx.input.getColPos(binding.pos()), binding.pos());
                            }
                            DefineSlotVariable(cx, binding.ref.name, binding.debug_name, binding.pos(),
                                                expr_type, (slot.getVarIndex()));
                        }
                    }
                }
            }
        }
View Full Code Here

        if( node.scope_chain != null )
        {
            saved_scopes = cx.swapScopeChain(node.scope_chain);
        }

        Slot getSlot = node.ref.getSlot(cx, GET_TOKEN);
        Slot setSlot = node.ref.getSlot(cx, SET_TOKEN);
        boolean with_this = getSlot instanceof MethodSlot || setSlot instanceof MethodSlot;

        ObjectValue fun = node.fun;
        cx.pushScope(fun.activation);

        // Do nested functions
        boolean needs_activation = false;

        if( node.fexprs.size() > 0 )
        {
            needs_activation = true;
        }
        if (node.isWithUsed())
        {
                needs_activation = true;
        }
        if (node.isExceptionsUsed())
        {
                needs_activation = true;
        }

/*
        for (int i = (node.fexprs == null) ? -1 : node.fexprs.size() - 1; i >= 0; i--)
        {
            Node fexpr = node.fexprs.get(i);
            fexpr.evaluate(cx, this);
        }
*/

        used_namespaces_sets.push_back(node.used_namespaces);

        for (FunctionCommonNode def : node.fexprs)
        {
            def.evaluate(cx, this);
        }

        // reset debug position.  nested Function evaulation above will have updated it, we need to reset to top of this function.
        if (cx.input != null)
        {
            setPosition(cx.input.getLnNum(node.pos()),cx.input.getColPos(node.pos()),node.pos());
        }

        pushStackFrame();

        frame.functionName = node.internal_name;
        frame.maxParams = node.signature.size();
        frame.maxLocals = node.body != null ? node.var_count : 0;
        frame.maxTemps = node.body != null ? node.temp_count : 0;
        frame.needsArguments = node.needsArguments;

        frame.withThis = with_this;

        frame.firstInnerScope = cx.getScopes().size()-1;
        if (with_this)
        {
            frame.firstInnerScope--;
        }

        // If there are nested functions, this will be true
        frame.activationIsExposed = needs_activation;
        frame.registerScopeIndex = needs_activation ? -1 : (cx.getScopes().size()-1);

        StartMethod(frame.functionName,frame.maxParams,frame.maxLocals,0,needs_activation,node.needsArguments);

        // If this is a constructor, then insert a call to the base constructor,
        // and the instance initializer

        if( "$construct".equals(node.ref.name) && cx.statics.es4_nullability  )
        {
          // Must run property initializers before this, or activation scope is pushed.  Setting properties
          // will be handled with getlocal0, setproperty and arguments will use getlocal since there can be no intervening
          // scopes at this point (even if the method later needs an activation object)
            doCtorSetup(node, cx, needs_activation);
        }
        if (with_this)
        {
            LoadThis();
            PushScope();
        }

        // initialize local variables that are in registers.

        ObjectValue activation = node.fun.activation;
        int firstlocal = node.signature.size();
        if (node.needsArguments != 0)
        {
            firstlocal++;
        }
        int reg_offset = activation.builder.reg_offset;
        int var_offset = activation.builder.var_offset;

        if (needs_activation)
        {
            NewActivation();
            int temp_activation_reg = allocateTemp();
            activation.builder.temp_reg = temp_activation_reg;
            Dup();
            StoreRegister(reg_offset+temp_activation_reg,TYPE_none);
            PushScope();

      // create a 'local' name for the activation object for the debugger to use
      DefineSlotVariable(cx, node.internal_name, node.debug_name, node.pos(), ObjectValue.objectPrototype.type, temp_activation_reg);
        }

        if (activation.slots != null)
        {
            int base_offset = needs_activation ? var_offset : reg_offset;

            for (Slot s: activation.slots)
            {
                int index = base_offset + s.getVarIndex();
                if ( s.needsInit() &&  s.getVarIndex() >= firstlocal)
                {
                    StoreDefaultValue(cx, index, s, needs_activation);
                }
            }
        }

        if (needs_activation)
        {
            // Copy the arguments into the activation object
            int n=frame.maxParams;
            if (node.needsArguments != 0) n++;
            for (int i=0; i<n; i++)
            {
                GetActivationObject(cx.getScopes().size()-1);
                LoadRegister(i+1,TYPE_object);
                StoreVar(i);
            }
        }

        // for debug purposes dump out the list of args
        ParameterListNode parms = node.signature.parameter;
        String[] arg_names = null;
    if (parms != null)
    {
            arg_names = new String[parms.items.size()];
      for(int i = 0; i < parms.items.size(); ++i )
            {
                ParameterNode parm = parms.items.at(i);
        ReferenceValue ref;
        Slot slot;
        if (parm == null)
          ; // no good
        else if ((ref = parm.ref) == null)
          ; // no good
        else if ((slot = ref.getSlot(cx)) == null)
          ; // no good
        else
        {
          TypeInfo expr_type = ref.getType(cx);
          DefineSlotVariable(cx, ref.name, ref.name, pos, expr_type, slot.getVarIndex());
                    arg_names[i] = ref.name;
        }
      }
    }

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.