Example #1
0
        public void Dump()
        {
            var sb = new CodeWriter();
            sb.AppendLine("state machine dump");

            foreach (var e in _events.Values)
            {
                sb.AppendComment();
                sb.AppendComment("event " + e.Name);
                foreach (var t in e.Triggers)
                {
                    sb.AppendLine("TRIGGER " + t.Name + " WHEN");
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "] AFTER [" + t.PostCondition + "]");
                }
            }

            foreach (var t in Guards)
            {
                sb.AppendLine("GUARD " + t.Name + " " + t.Type + " WHEN ");
                if (t.Type == GuardType.TRANSITION)
                {
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "]");
                    sb.AppendLine("  AFTER [" + t.PostCondition + "]");
                }
                else if (t.Type == GuardType.ENTER)
                {
                    sb.AppendLine("  AFTER [" + t.PostCondition + "]");
                }
                else if (t.Type == GuardType.LEAVE)
                {
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "]");
                }
            }
            // sb.AppendLine("matrix:\n" + _matrix);

            Trace("{0}", sb);
        }
Example #2
0
        private void EmitTriggerStateChange(CodeWriter writer, IEnumerable<Trigger> triggers)
        {
            writer.AppendComment();
            writer.AppendComment("state transition");

            foreach (var t in triggers)
            {
                if(t.PreCondition.Type == GateType.Fixed)
                {
                    continue;
                }

                var c = _gc.ConvertToGate(0, t.PreCondition);

                EmitIfHeader(c);
                EmitEnterBlock();

                writer.AppendComment("transition " + t);
                foreach (var x in t.Transitions)
                {
                    EmitVariableAssignment(x.Variable, x.SinglePostStateIndex);
                }

                EmitLeaveBlock();
            }
        }
Example #3
0
 public JScriptCodeGenerator(CodeWriter writer)
     : base(writer)
 {
 }
Example #4
0
 protected CodeGenerator(CodeWriter writer)
 {
     this._writer = writer;
     _gc = null;
     Parameters = new CodeParameters();
 }
Example #5
0
 public CSharpCodeGenerator(CodeWriter writer)
     : base(writer)
 {
 }
Example #6
0
        public void GenerateCode()
        {
            _writer = null;
            _cg = null;

            SelectCodeGenerator();
            SM.Calculate();
            _cg.Emit(SM);
        }
Example #7
0
 private void EstablishCodeWriter()
 {
     if (null == _writer)
     {
         _writer = new CodeWriter();
     }
 }
Example #8
0
 public PseudoCodeGenerator(CodeWriter writer)
     : base(writer)
 {
 }