⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fsnewfunction2.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }

        if (obj.actions != null)
        {
            actions = new ArrayList(obj.actions.size());
            
            for (Iterator i = obj.actions.iterator(); i.hasNext();)
                actions.add(((FSActionObject)i.next()).clone());
        }
    }    

    /** Adds the name of an argument to the array of argument names.

        @param anArgument the name of an argument passed to the FSNewFunction object.
        */
    public void add(FSRegisterVariable anArgument)
    {
        arguments.add(anArgument); 
    }

    /** Adds the action object to the array of actions.

        @param anAction an object belonging to a class derived from FSActionObject.
        */
    public void add(FSActionObject anAction)
    {
        actions.add(anAction);
    }

    /** Gets the name of the function.

        @return the name of the function.
        */
    public String getName() 
    {
        return name;
    }
    
    /** Sets the name of the function. The name may be null when defining methods.

        @param aString the name of the function or null for a method.
        */
    public void setName(String aString) 
    {
        name = aString;
    }

    /** 
     * Gets the number of registers to allocate for function variables.
     * 
     * @return the number of registers to allocate.
     */
    public int getRegisterCount()
    {
        return registerCount;
    }
    
    /**
     * Sets the number of registers to allocate for function variables. Up to
     * 256 registers may be allocated for each function.
     * 
     * @param count the number of registers to allocate.
     */
    public void setRegisterCount(int count)
    {
        registerCount = count;
    }

    /** 
     * Get the code containing the compound flags that control the execution environment
     * of the function or method.
     *
     * @return the code for the optimizations.
     */
    public int getOptimizations()
    {
        return optimizations;
    }
    
    /** 
     * Set the code containing the compound flags that control the execution environment
     * of the function or method.
     *
     * @param code the compound code can be created by bitwise-ORing the constants that 
     * identify the optimizations performed.
     */
    public void setOptimizations(int code)
    {
        optimizations = code;
    }

    /** 
     * Gets the array of FSRegisterVariables that define the function arguments and whether
     * they are assigned to internal registers or to local variables in memory.

        @return the array of FSRegisterVariables that define the functions arguments.
        */
    public ArrayList getArguments() 
    {
        return arguments;
    }

    /**
     * Sets the array of FSRegisterVariables that define the function arguments and whether
     * they are assigned to internal registers or to local variables in memory.
     *
     * @param anArray an array of Strings listing the names of the arguments.
     */
    public void setArguments(ArrayList anArray) 
    {
        arguments = anArray;
    }

    /** Gets the actions executed by the function.

        @return the array of actions executed.
        */
    public ArrayList getActions() 
    {
        return actions;
    }

    /** Sets the actions.

        @param anArray the array of actions that define the operation performed by the function.
        */
    public void setActions(ArrayList anArray) 
    {
        actions = anArray;
    }

    public Object clone()
    {
        FSNewFunction2 anObject = (FSNewFunction2)super.clone();
        
         anObject.arguments = new ArrayList();
            
        for (Iterator i = arguments.iterator(); i.hasNext();)
            anObject.arguments.add((FSRegisterVariable)((FSRegisterVariable)i.next()).clone());

        anObject.actions = new ArrayList();
            
        for (Iterator i = actions.iterator(); i.hasNext();)
            anObject.actions.add(((FSActionObject)i.next()).clone());

        return anObject;
    }

    public boolean equals(Object anObject)
    {
        boolean result = false;
        
        if (super.equals(anObject))
        {
            FSNewFunction2 typedObject = (FSNewFunction2)anObject;
            
            if (name != null)
                result = name.equals(typedObject.name);
            else
                result = name == typedObject.name;
                
            result = result && registerCount == typedObject.registerCount;
            result = result && optimizations == typedObject.optimizations;

            if (arguments != null)
                result = result && arguments.equals(typedObject.arguments);
            else
                result = result && arguments == typedObject.arguments;

            if (actions != null)
                result = result && actions.equals(typedObject.actions);
            else
                result = result && actions == typedObject.actions;
        }
        return result;
    }

    public void appendDescription(StringBuffer buffer, int depth)
    {
        buffer.append(name());
        
        if (depth > 0)
        {
            buffer.append(": { ");
            Transform.append(buffer, "name", name);        
            Transform.append(buffer, "registerCount", registerCount);
            Transform.append(buffer, "optimizations", optimizations);
            Transform.append(buffer, "arguments", arguments, depth);
            Transform.append(buffer, "actions", actions, depth);
            buffer.append("}");
        }
    }

    public int length(FSCoder coder)
    { 
        super.length(coder);
        
        length += (name != null) ? coder.strlen(name, true) : 1;
        length += 5;
        
        for (int i=0; i<arguments.size(); i++)
            length += ((FSRegisterVariable)arguments.get(i)).length(coder);
        
        length += 2;
        
        _actionsLength = 0;

        for (Iterator i = actions.iterator(); i.hasNext();)
        {
            FSActionObject currentAction = (FSActionObject)i.next();
            
            _actionsLength += currentAction.length(coder);
            _actionsLength += (currentAction.getType() > 128) ? 3 : 1;
        }
        length += _actionsLength;
        
        return length;
    }
        
    public void encode(FSCoder coder) 
    {
        coder.beginObject(name());

        coder.writeWord(type, 1);
        coder.writeWord(length - _actionsLength, 2);

        if (name != null)
            coder.writeString(name);

        coder.writeWord(0, 1);

        coder.writeWord(arguments.size(), 2);
        coder.writeWord(registerCount, 1);
        coder.writeBits(optimizations, 16);

        for (Iterator i = arguments.iterator(); i.hasNext();)
            ((FSRegisterVariable)i.next()).encode(coder);

        coder.writeWord(_actionsLength, 2);
           
        for (Iterator i=actions.iterator(); i.hasNext();)
        {
            FSActionObject action = (FSActionObject)i.next();
                
            int objStart = coder.getPointer();
            int start = coder.getPointer() + ((action.getType() > 128) ? 24 : 8);
            int next = start + (action.getLength() << 3);
            
            action.encode(coder);
            coder.setPointer(next);
            
            int delta = (coder.getPointer() - next) >> 3;
            
            if (delta != 0)
            {
                coder.context[FSCoder.CodingError] = 1;
                coder.context[FSCoder.TypeInError] = action.getType();
                coder.context[FSCoder.StartOfError] = objStart >>> 3;
                coder.context[FSCoder.ExpectedLength] = (next-objStart)>>>3;
                coder.context[FSCoder.Delta] = delta;
            }
        }

        coder.endObject(name());
    }
    
    public void decode(FSCoder coder)
    {
        int argumentCount = 0;
        int bytesRead = 0;
        
        arguments = new ArrayList();
        actions = new ArrayList();

        super.decode(coder);

        name = coder.readString();
        
        argumentCount = coder.readWord(2, false);
        registerCount = coder.readWord(1, false);
        optimizations = coder.readBits(16, false);
        
        for (int i=0; i<argumentCount; i++)
            arguments.add(new FSRegisterVariable(coder));

        _actionsLength = coder.readWord(2, false);
        length += _actionsLength;
        
        while (bytesRead < _actionsLength)
        {
            FSActionObject anAction = FSMovie.decodeAction(coder);
            
            bytesRead += anAction.getLength() + ((anAction.getType() >= 128) ? 3 : 1);
            actions.add(anAction);
        }

        coder.endObject(name());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -