Esempio n. 1
0
 public CSLite_Scripter()
 {
     this.ch = null;
     this.rh = null;
     this.CSLiteException = null;
     this.RunCount = 0;
     this.scripter = new BaseScripter(this);
     this.scripter.RegisterParser(new CSharp_Parser());
     //this.scripter.RegisterParser(new VB_Parser());
     //this.scripter.RegisterParser(new Pascal_Parser());
     this.state = ScripterState.None;
     this.SetState(ScripterState.Init);
 }
Esempio n. 2
0
 private void SetState(ScripterState value)
 {
     if ((this.ch != null) && (this.state != value)) {
         this.ch(this, new CSLiteChangeStateEventArgs(this.state, value));
     }
     this.state = value;
 }
Esempio n. 3
0
 private void MatchState(ScripterState s)
 {
     if (this.state != s) {
         this.RaiseErrorEx("CSLite0004. Incorrect scripter state. Expected '{0}'", new object[] { s.ToString() });
     }
 }
Esempio n. 4
0
        public void LoadCompiledModuleFromFile(string module_name, string file_name)
        {
            if (!this.HasErrors) {
                switch (this.state) {
                    case ScripterState.Init:
                    case ScripterState.ReadyToCompile:
                        this.scripter.LoadCompiledModuleFromFile(module_name, file_name);
                        if (!this.HasErrors) {
                            this.state = ScripterState.ReadyToCompile;
                            break;
                        }
                        this.SetState(ScripterState.Error);
                        break;

                    default:
                        this.MatchState(ScripterState.Init);
                        break;
                }
            }
        }
Esempio n. 5
0
 public void Link()
 {
     if (!this.HasErrors) {
         switch (this.state) {
             case ScripterState.Init:
             case ScripterState.ReadyToCompile:
                 this.Compile();
                 if (this.HasErrors) {
                     return;
                 }
                 break;
         }
         this.MatchState(ScripterState.ReadyToLink);
         if (!this.HasErrors) {
             this.state = ScripterState.Linking;
             this.scripter.Link();
             if (this.HasErrors) {
                 this.SetState(ScripterState.Error);
             }
             else {
                 this.SetState(ScripterState.ReadyToRun);
             }
         }
     }
 }
Esempio n. 6
0
        public void AddCodeLine(string module_name, string text)
        {
            if (!this.HasErrors) {
                switch (this.state) {
                    case ScripterState.Init:
                    case ScripterState.ReadyToCompile:
                        this.scripter.AddCodeLine(module_name, text);
                        if (!this.HasErrors) {
                            this.state = ScripterState.ReadyToCompile;
                            break;
                        }
                        this.SetState(ScripterState.Error);
                        break;

                    default:
                        this.MatchState(ScripterState.Init);
                        break;
                }
            }
        }
 public CSLiteChangeStateEventArgs(ScripterState old_state, ScripterState new_state)
 {
     this.OldState = old_state;
     this.NewState = new_state;
 }