Example #1
0
 protected override void Deserialize(CodeReader reader)
 {
     this.Child = (EngineContextNodeBase)EngineContextFactory.Create(reader);
 }
Example #2
0
        internal static IContextSerializer Create(CodeReader reader)
        {
            IContextSerializer instance = null;
            Type     t;
            int      idx;
            Delegate d;

            switch (reader.Current)
            {
            case 'u':       //root
                if (reader.TryRead(3) == WorkflowCommonDefs.CompilerNodeRoot)
                {
                    reader.Ptr += 3;
                    instance    = new EngineContextRoot();
                    instance.Deserialize(reader);
                }
                break;

            case WorkflowCommonDefs.CompilerTypeVoid:       //nop
                reader.Ptr++;
                instance = new EngineContextNop();
                instance.Deserialize(reader);
                break;

            case 'v':       //local-var declaration
                reader.Ptr++;
                t        = GetTypeFromTag(reader.Read());
                idx      = reader.ReadIndex();
                instance = new EngineVariableTemplate(t, idx.ToString());
                instance.Deserialize(reader);
                break;

            case 'F':       //global-func reference
                reader.Ptr++;
                idx      = reader.ReadIndex();
                d        = reader.GlobalFuncs[idx];
                instance = CreateFunc(d);
                instance.Deserialize(reader);
                break;

            case 'f':       //local-func reference
                throw new NotSupportedException();

            case 'L':       //global-var reference
                reader.Ptr++;
                idx      = reader.ReadIndex();
                instance = new EngineContextGlobalVarReference(idx);
                instance.Deserialize(reader);
                break;

            case 'l':       //local-var reference
                reader.Ptr++;
                idx      = reader.ReadIndex();
                instance = new EngineContextLocalVarReference(idx);
                instance.Deserialize(reader);
                break;

            case 'K':       //constant value
                reader.Ptr++;
                t        = GetTypeFromTag(reader.Read());
                instance = new EngineContextConstantValue(t);
                instance.Deserialize(reader);
                break;

            case 'C':       //cast
                reader.Ptr++;
                t        = GetTypeFromTag(reader.Read());
                instance = new EngineContextCast(
                    GetTypeFromTag(reader.Read()),
                    t);
                instance.Deserialize(reader);
                break;

            case 'S':       //statement
                if (reader.TryRead(2) == WorkflowCommonDefs.CompilerNodeStatementSequence)
                {
                    reader.Ptr += 2;
                    instance    = new EngineContextSequence();
                    instance.Deserialize(reader);
                }
                else if (reader.TryRead(2) == WorkflowCommonDefs.CompilerNodeStatementAssign)
                {
                    reader.Ptr += 2;
                    instance    = new EngineContextAssign();
                    instance.Deserialize(reader);
                }
                else if (reader.TryRead(2) == WorkflowCommonDefs.CompilerNodeStatementWhile)
                {
                    reader.Ptr += 2;
                    instance    = new EngineContextWhile();
                    instance.Deserialize(reader);
                }
                else if (reader.TryRead(2) == WorkflowCommonDefs.CompilerNodeStatementIf)
                {
                    reader.Ptr += 2;
                    instance    = new EngineContextIf();
                    instance.Deserialize(reader);
                }
                break;
            }

            if (instance == null)
            {
                throw new NotSupportedException();
            }

            return(instance);
        }
 protected override void Deserialize(CodeReader reader)
 {
     //do nothing
 }
 void IContextSerializer.Deserialize(CodeReader reader)
 {
     //do nothing
 }