📄 fsaction.java
字号:
/*
* FSAction.java
* Transform
*
* Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Flagstone Software Ltd. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.flagstone.transform;
/**
The FSAction class is used to represent stack-based actions, defined by simple byte-codes, that
are executed by the Flash Player.
<p>The operations supported by the FSAction class are:</p>
<h1 class="datasheet">Stack Manipulation</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>Pop</td>
<td>Pop value from the top of the stack.</td>
<td nowrap>(valueA -- )</td>
<td nowrap>(4 -- )</td></tr>
<tr valign="top"><td>Duplicate</td>
<td>Duplicate the value at the top of the stack.</td>
<td nowrap>(valueA -- valueA valueA)</td>
<td nowrap>(4 -- 4 4)</td></tr>
<tr valign="top"><td>Swap</td>
<td>Swap the top two values on the stack.</td>
<td nowrap>(valueA valueB -- valueB valueA)</td>
<td nowrap>(4 3 -- 3 4)</td></tr>
</table>
<p>FSPush is used to push literals onto the Stack. See also FSRegisterCopy which
copies the value on top of the Stack to one of the Flash Player's internal
registers.</p>
<h1 class="datasheet">Arithmetic</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>Add</td>
<td>Arithmetic Add: A + B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 3 -- 7)</td></tr>
<tr valign="top"><td>Subtract</td>
<td>Arithmetic Subtract: A - B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 3 -- 1)</td></tr>
<tr valign="top"><td>Multiply</td>
<td>Arithmetic Multiply: A * B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 3 -- 12)</td></tr>
<tr valign="top"><td>Divide</td>
<td>Arithmetic Divide: A / B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 3 -- 1.333)</td></tr>
<tr valign="top"><td>Modulo</td>
<td>Arithmetic Modulo: A % B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 3 -- 1)</td></tr>
<tr valign="top"><td>Increment</td>
<td>Add 1 to the value on the stack.</td>
<td nowrap>(num -- num)</td>
<td nowrap>(3 -- 4)</td></tr>
<tr valign="top"><td>Decrement</td>
<td>Subtracted 1 from the value on the stack.</td>
<td nowrap>(num -- num)</td>
<td nowrap>(4 -- 3)</td></tr>
</table>
<p>Arithmetic add is supported by two actions. IntegerAdd was introduced in Flash 4.
It was replaced in Flash 5 by the more flexible Add action which is able to add
any two numbers and also concatenate strings. If a string and a number are added
then the number is converted to its string representation before concatenation.</p>
<h1 class="datasheet">Comparison</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>Less</td>
<td>LessThan: A < B</td>
<td nowrap>(numA numB -- boolean)</td>
<td nowrap>(10 9 -- 0 )</tr>
<tr valign="top"><td>StringLess</td>
<td>String compare: stringA < stringB</td>
<td nowrap>(stringA stringB -- boolean)</td>
<td nowrap>("abc" "ab" -- 0)</td></tr>
<tr valign="top"><td>Equals</td>
<td>Equals: A == B</td>
<td nowrap>(numA numB -- boolean)</td>
<td nowrap>(23 23 -- 1 )</tr>
<tr valign="top"><td>StringEquals</td>
<td>String compare: stringA == stringB</td>
<td nowrap>(stringA stringB -- boolean)</td>
<td nowrap>("abc" "abc" -- 1)</td></tr>
<tr valign="top"><td>StrictEquals</td>
<td>Equals: A === B, are the types as well as the values equal.</td>
<td nowrap>(valueA valueB -- boolean)</td>
<td nowrap>("23" 23 -- 0 )</tr>
<tr valign="top"><td>Greater</td>
<td>Greater Than: A > B</td>
<td nowrap>(numA numB -- boolean)</td>
<td nowrap>(10 9 -- 0 )</tr>
<tr valign="top"><td>StringGreater</td>
<td>String compare: stringA > stringB</td>
<td nowrap>(stringA stringB -- boolean)</td>
<td nowrap>("abc" "ab" -- 0)</td></tr>
</table>
<p>The less than comparison is supported by IntegerLess introduced in Flash 4
and Less introduced in Flash 5. The Less action is more flexible allowing comparison
between any combination of two numbers and strings. In Flash 4 comparisons were
only supported on values of the same type using either IntegerLess or StringLess.</p>
<p>The equals comparison is supported by IntegerEquals introduced in Flash 4 and
Equals introduced in Flash 5. The Equals action is more flexible allowing
comparison between any combination of two numbers and strings. In Flash 4
comparisons were only supported on values of the same type using either
IntegerEquals or StringEquals.</p>
<h1 class="datasheet">Logical</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>And</td>
<td>Logical And: A && B</td>
<td nowrap>(numA numB -- boolean)</td>
<td nowrap>(3 0 -- 0)</td></tr>
<tr valign="top"><td>Or</td>
<td>Logical Or: A || B</td>
<td nowrap>(numA numB -- boolean)</td>
<td nowrap>(3 0 -- 1)</td></tr>
<tr valign="top"><td>Not</td>
<td>Logical Not: !A</td>
<td nowrap>(num -- boolean)</td>
<td nowrap>(3 -- 0)</td></tr>
</table>
<h1 class="datasheet">Bitwise</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>BitwiseAnd</td>
<td>Bitwise And: A & B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(5 4 -- 4)</td></tr>
<tr valign="top"><td>BitwiseOr</td>
<td>Bitwise Or: A | B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(5 4 -- 5)</td></tr>
<tr valign="top"><td>BitwiseXOr</td>
<td>Bitwise Exclusive-Or: A ^ B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(5 4 -- 1)</td></tr>
<tr valign="top"><td>LogicalShiftLeft</td>
<td>Logical Shift Left: A << B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(4 1 -- 8)</td></tr>
<tr valign="top"><td>LogicalShiftRight</td>
<td>Logical Shift Right: A >>> B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(8 1 -- 4)</td></tr>
<tr valign="top"><td>ArithmeticShiftRight</td>
<td>Arithmetic Shift Right (sign extension): A >> B</td>
<td nowrap>(numA numB -- num)</td>
<td nowrap>(-1 1 -- -1)</td></tr>
</table>
<h1 class="datasheet">String</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>StringAdd</td>
<td>Concatenate two strings</td>
<td nowrap>(string string -- string)</td>
<td nowrap>("ab" "cd" -- "abcd")</td></tr>
<tr valign="top"><td>StringLength</td>
<td>Returns the length of a string</td>
<td nowrap>(string -- num)</td>
<td nowrap>("abc" -- 3)</td></tr>
<tr valign="top"><td>MBStringLength</td>
<td>Returns the length of a string that contains characters from an extended set such as Unicode.</td>
<td nowrap>(string -- num)</td>
<td nowrap>("abc" -- 3)</td></tr>
<tr valign="top"><td>StringExtract</td>
<td>Substring. Extract <I>count</I> characters from string starting at position <em>index</em>.</td>
<td nowrap>(count index string -- string)</td>
<td nowrap>(3 2 "abcde" -- "bcd")</td></tr>
<tr valign="top"><td>MBStringExtract</td>
<td>Multi-byte Substring. Extract <I>count</I> characters from string starting at position <em>index</em>.</td>
<td nowrap>(count index string -- string)</td>
<td nowrap>(3 2 "abcde" -- "bcd")</td></tr>
</table>
<h1 class="datasheet">Type Conversion</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>ToInteger</td>
<td>Converts the value to an integer</td>
<td nowrap> ( num -- num)</td>
<td nowrap> ( 3.2 -- 3 )</tr>
<tr valign="top"><td>ToNumber</td>
<td>Converts the string value to a number.</td>
<td nowrap> ( string -- num)</td>
<td nowrap> ( "3.2" -- 3.2 )</tr>
<tr valign="top"><td>ToString</td>
<td>Converts the value to a string.</td>
<td nowrap> ( num -- string)</td>
<td nowrap> ( 3.2 -- "3.2" )</tr>
<tr valign="top"><td>CharToAscii</td>
<td>Convert the first character of a string to its ASCII value.</td>
<td nowrap>(string -- num)</td>
<td nowrap>("abc" -- 97)</td></tr>
<tr valign="top"><td>MBCharToAscii</td>
<td>Convert the first character of string to its Unicode value.</td>
<td nowrap>(string -- num)</td>
<td nowrap>("abc" -- 61)</td></tr>
<tr valign="top"><td>AsciiToChar</td>
<td>Convert the ASCII value to the equivalent character.</td>
<td nowrap>(num -- string)</td>
<td nowrap>(97 -- "a")</td></tr>
<tr valign="top"><td>MBAsciiToChar</td>
<td>Convert a Unicode value to the equivalent character.</td>
<td nowrap>(num -- string)</td>
<td nowrap>(61 -- "a")</td></tr>
</table>
<h1 class="datasheet">Variables</h1>
<table class="actions">
<tr><th>Action</th><th>Description</th><th>Stack Notation</th><th>Example</th></tr>
<tr valign="top"><td>GetVariable</td>
<td>Push the value for the specified variable on the stack</td>
<td nowrap>(variableName -- value)</td>
<td nowrap>("FlashVersion" -- 4)</td></tr>
<tr valign="top"><td>SetVariable</td>
<td>Set the value of the specified variable</td>
<td nowrap>(variableName value --)</td>
<td nowrap>("Var1" 123 --)</td></tr>
<tr valign="top"><td>GetType</td>
<td>Returns the type of the object or value at the top of the stack.</td>
<td nowrap>(value -- value type)</td>
<td nowrap>(--)</td></tr>
<tr valign="top"><td>NewVariable</td>
<td>Create a new user-defined variable.</td>
<td nowrap>(name --)</td>
<td nowrap>("x" --)</td></tr>
<tr valign="top"><td>InitVariable</td>
<td>Create and initialise a user-defined variable.</td>
<td nowrap>(value name --)</td>
<td nowrap>(1 "x" --)</td></tr>
<tr valign="top"><td>NewArray</td>
<td>Create an array.</td>
<td nowrap>(value+ count -- array)</td>
<td nowrap>(1 2 3 4 4 -- array)</td></tr>
<tr valign="top"><td>DeleteVariable</td>
<td>Deletes a variable, returning true if the variable was deleted, false otherwise.</td>
<td nowrap>(name -- boolean)</td>
<td nowrap>("x" -- 1)</td></tr>
<tr valign="top"><td>Delete</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -