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

📄 smcvbgenerator.java

📁 SMC takes a state machine stored in a .sm file and generates a State pattern in twelve programming l
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            _source.print(indent1);            _source.println("End If");            _source.println();        }        // Dump out the exit actions - but only for the first        // guard.        // v. 1.0, beta 3: Not any more. The exit actions are        // executed only if 1) this is a standard, non-loopback        // transition or a pop transition.        if (transType == Smc.TRANS_POP || loopbackFlag == false)        {            indent3 = indent1;            // If this is a non-loopback, generic transition,            // do runtime loopback checking.            if (transType == Smc.TRANS_SET &&                defaultFlag == true)            {                indent3 = indent1 + "    ";                _source.print(indent1);                _source.println("If loopbackFlag = False _");                _source.print(indent1);                _source.println("Then");            }            _source.print(indent3);            _source.println("context.State.Exit_(context)");            if (transType == Smc.TRANS_SET &&                defaultFlag == true)            {                _source.print(indent1);                _source.println("End If");                _source.println();            }        }        // Dump out this transition's actions.        if (actions.size() == 0)        {            if (condition.length() > 0)            {                _source.print(indent1);                _source.println("' No actions.");            }            indent2 = indent1;        }        else        {            String tempIndent;            // Now that we are in the transition, clear the            // current state.            _source.print(indent1);            _source.println("context.ClearState()");            // v. 2.0.0: Place the actions inside a try/finally            // block. This way the state will be set before an            // exception leaves the transition method.            // v. 2.2.0: Check if the user has turned off this            // feature first.            if (Smc.isNoCatch() == false)            {                _source.print(indent1);                _source.println("Try");                indent2 = indent1 + "    ";            }            else            {                indent2 = indent1;            }            tempIndent = _indent;            _indent = indent2;            for (SmcAction action: actions)            {                action.accept(this);            }            _indent = tempIndent;            // v. 2.2.0: Check if the user has turned off this            // feature first.            if (Smc.isNoCatch() == false)            {                _source.print(indent1);                _source.println("Finally");            }        }        // Print the setState() call, if necessary. Do NOT        // generate the set state it:        // 1. The transition has no actions AND is a loopback OR        // 2. This is a push or pop transition.        if (transType == Smc.TRANS_SET &&            (actions.size() > 0 || loopbackFlag == false))        {            _source.print(indent2);            _source.print("context.State = ");            _source.println(fqEndStateName);        }        else if (transType == Smc.TRANS_PUSH)        {            // Set the next state so this it can be pushed            // onto the state stack. But only do so if a clear            // state was done.            if (loopbackFlag == false || actions.size() > 0)            {                _source.print(indent2);                _source.print("context.State = ");                _source.println(fqEndStateName);            }            // Before doing the push, execute the end state's            // entry actions (if any) if this is not a loopback.            if (loopbackFlag == false)            {                indent3 = indent2;                if (defaultFlag == true)                {                    indent3 = indent2 + "    ";                    _source.println();                    _source.print(indent2);                    _source.println("If loopbackFlag = False _");                    _source.print(indent2);                    _source.println("Then");                }                _source.print(indent3);                _source.println("context.State.Entry(context)");                if (defaultFlag == true)                {                    _source.print(indent3);                    _source.println("End If");                }            }            _source.print(indent2);            _source.print("context.PushState(");            _source.print(pushStateName);            _source.println(")");        }        else if (transType == Smc.TRANS_POP)        {            _source.print(indent1);            _source.println("context.PopState()");        }        // Perform the new state's enty actions.        // v. 1.0, beta 3: Not any more. The entry actions are        // executed only if 1) this is a standard, non-loopback        // transition or a push transition.        if ((transType == Smc.TRANS_SET &&             loopbackFlag == false) ||             transType == Smc.TRANS_PUSH)        {            indent3 = indent2;            // If this is a non-loopback, generic transition,            // do runtime loopback checking.            if (transType == Smc.TRANS_SET &&                defaultFlag == true)            {                indent3 = indent2 + "    ";                _source.println();                _source.print(indent2);                _source.println("If loopbackFlag = False _");                _source.print(indent2);                _source.println("Then");            }            _source.print(indent3);            _source.println("context.State.Entry(context)");            if (transType == Smc.TRANS_SET &&                defaultFlag == true)            {                _source.print(indent2);                _source.println("End If");                _source.println();            }        }        // If there was a try/finally, then put the closing        // brace on the finally block.        // v. 2.2.0: Check if the user has turned off this        // feature first.        if (actions.size() > 0 && Smc.isNoCatch() == false)        {            _source.print(indent1);            _source.println("End Try");        }        // If there is a transition associated with the pop, then        // issue that transition here.        if (transType == Smc.TRANS_POP &&            endStateName.equals(NIL_STATE) == false &&            endStateName.length() > 0)        {            String popArgs = guard.getPopArgs();            _source.println();            _source.print(indent1);            _source.print("context.");            _source.print(endStateName);            _source.print("(");            // Output any and all pop arguments.            if (popArgs.length() > 0)            {                _source.print(popArgs);            }            _source.println(")");        }        return;    } // end of visit(SmcGuard)    public void visit(SmcAction action)    {        String name = action.getName();        List<String> arguments = action.getArguments();        Iterator<String> it;        String sep;        // Need to distinguish between FSMContext actions and        // application class actions. If the action is        // "emptyStateStack", then pass it to the context.        // Otherwise, let the application class handle it.        if (name.compareTo("EmptyStateStack") == 0)        {            _source.print(_indent);            _source.println("context.EmptyStateStack()");        }        // If this is a property assignment, then strip the        // semicolon from the argument's end.        else if (action.isProperty() == true)        {            String arg = (String) arguments.get(0);            _source.print(_indent);            _source.print("ctxt.");            _source.print(name);            _source.print(" = ");            _source.println(arg.substring(0, arg.indexOf(';')));        }        else        {            _source.print(_indent);            _source.print("ctxt.");            _source.print(name);            _source.print("(");            for (it = arguments.iterator(), sep = "";                 it.hasNext() == true;                 sep = ", ")            {                _source.print(sep);                _source.print(it.next());            }            _source.println(")");        }        return;    } // end of visit(SmcAction)    public void visit(SmcParameter parameter)    {        _source.print("ByVal ");        _source.print(parameter.getName());        _source.print(" As ");        _source.print(parameter.getType());        return;    } // end of visit(SmcParameter)//---------------------------------------------------------------// Member data//} // end of class SmcVBGenerator//// CHANGE LOG// $Log: SmcVBGenerator.java,v $// Revision 1.10  2008/03/21 14:03:17  fperrad// refactor : move from the main file Smc.java to each language generator the following data ://  - the default file name suffix,//  - the file name format for the generated SMC files//// Revision 1.9  2007/02/21 13:57:07  cwrapp// Moved Java code to release 1.5.0//// Revision 1.8  2007/01/15 00:23:52  cwrapp// Release 4.4.0 initial commit.//// Revision 1.7  2006/09/23 14:28:19  cwrapp// Final SMC, v. 4.3.3 check-in.//// Revision 1.6  2006/09/16 15:04:29  cwrapp// Initial v. 4.3.3 check-in.//// Revision 1.5  2006/07/11 18:18:37  cwrapp// Corrected owner property.//// Revision 1.4  2006/06/03 19:39:25  cwrapp// Final v. 4.3.1 check in.//// Revision 1.3  2005/11/07 19:34:54  cwrapp// Changes in release 4.3.0:// New features://// + Added -reflect option for Java, C#, VB.Net and Tcl code//   generation. When used, allows applications to query a state//   about its supported transitions. Returns a list of transition//   names. This feature is useful to GUI developers who want to//   enable/disable features based on the current state. See//   Programmer's Manual section 11: On Reflection for more//   information.//// + Updated LICENSE.txt with a missing final paragraph which allows//   MPL 1.1 covered code to work with the GNU GPL.//// + Added a Maven plug-in and an ant task to a new tools directory.//   Added Eiten Suez's SMC tutorial (in PDF) to a new docs//   directory.//// Fixed the following bugs://// + (GraphViz) DOT file generation did not properly escape//   double quotes appearing in transition guards. This has been//   corrected.//// + A note: the SMC FAQ incorrectly stated that C/C++ generated//   code is thread safe. This is wrong. C/C++ generated is//   certainly *not* thread safe. Multi-threaded C/C++ applications//   are required to synchronize access to the FSM to allow for//   correct performance.//// + (Java) The generated getState() method is now public.//// Revision 1.2  2005/08/26 15:21:34  cwrapp// Final commit for release 4.2.0. See README.txt for more information.//// Revision 1.1  2005/05/28 19:28:43  cwrapp// Moved to visitor pattern.//// Revision 1.2  2005/02/21 15:38:51  charlesr// Added Francois Perrad to Contributors section for Python work.//// Revision 1.1  2005/02/21 15:23:02  charlesr// Modified isLoopback() method call to new signature due to moving// the method from SmcGuard to SmcCodeGenerator.//// Revision 1.0  2005/02/03 17:12:57  charlesr// Initial revision//

⌨️ 快捷键说明

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