From: Jan T. <de...@us...> - 2002-05-15 18:24:29
|
Update of /cvsroot/net-script/netscript2/src/perl/NetScript In directory usw-pr-cvs1:/tmp/cvs-serv18312 Modified Files: Interpreter.pm Log Message: * added variable state controls * included ControlStructuresLibrary Index: Interpreter.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/NetScript/Interpreter.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Interpreter.pm 11 May 2002 13:12:35 -0000 1.6 --- Interpreter.pm 15 May 2002 18:24:27 -0000 1.7 *************** *** 8,11 **** --- 8,12 ---- # mailto: ko...@in... #-------------------------------------------------------- + use strict; #/** *************** *** 17,22 **** package NetScript::Interpreter; - use strict; - #-------------------------------------------------------- # IMPORTS --- 18,21 ---- *************** *** 24,27 **** --- 23,27 ---- use CGI; use XML::Parser; + use NetScript::Engine::State; use NetScript::Engine::DOMWalker; use NetScript::Engine::Event; *************** *** 30,33 **** --- 30,34 ---- use NetScript::Libraries::DefaultLibrary; use NetScript::Libraries::DebugLibrary; + use NetScript::Libraries::ControlStructuresLibrary; use NetScript::Util::XMLParserRelay; use NetScript::Util::FileRetriever; *************** *** 38,45 **** use XML::DOM2::XMLDOMWriterStyle; ! #-------------------------------------------------------- # Globals ! #-------------------------------------------------------- ! our $VERSION = '2.0'; # Current Version of Class # This is for catching errors at compile-time --- 39,57 ---- use XML::DOM2::XMLDOMWriterStyle; ! ! #----------------------------------------------------------- # Globals ! #----------------------------------------------------------- ! #/** ! # The current Version of NetScript ! #*/ ! our $VERSION = '2.0 ($Date$)'; ! ! #/** ! # The namespace URI of all NetScript related tags. ! # (http://netscript.insomnia-hq.de). ! #*/ ! our $NAMESPACE_URI = "http://netscript.insomnia-hq.de"; ! # This is for catching errors at compile-time *************** *** 61,65 **** print $msg; } - set_message(\&handle_errors); } --- 73,76 ---- *************** *** 88,91 **** --- 99,104 ---- $this -> { m_StatementEvaluator } = NetScript::Engine::StatementEvaluator -> new( $this ); + $this -> { m_currentState } = + NetScript::Engine::State -> new(); my $defLib = NetScript::Libraries::DefaultLibrary -> new(); *************** *** 94,97 **** --- 107,114 ---- my $debugLib = NetScript::Libraries::DebugLibrary -> new(); $debugLib -> init( $this ); + + my $csLib = NetScript::Libraries::ControlStructuresLibrary -> new(); + $csLib -> init( $this ); + return $this; # return Object } *************** *** 206,209 **** --- 223,258 ---- my ($this) = @_; return $this -> { m_StatementEvaluator }; + } + + + #/** + # Returns the current variable state + # @public + # @return an instance of <code>NetScript::Engine::State</code> + #*/ + sub getState { + my ( $this ) = @_; + $this -> { m_currentState }; + } + + #/** + # Creates a new state and sets this as top state. + # @public + #*/ + sub newState { + my ( $this ) = @_; + my $state = NetScript::Engine::State -> new( $this -> getState() ); + $this -> { m_currentState } = $state; + } + + #/** + # Drops the current state and sets its parent + # as new current state. + # @public + #*/ + sub dropState { + my ( $this ) = @_; + my $parent = $this -> { m_currentState } -> getParent(); + $this -> { m_currentState } = $parent; } |