Esempio n. 1
0
 public void AddRetrunOperator(ref TICInstruction _instruction)
 {
     _instruction.Operator.NoOfArg    = 1;
     _instruction.Operator.OpCode     = (int)OPCODES.RETURN_VALUE;
     _instruction.Operator.ReturnType = m_Type;
     _instruction.OperandList.Add(GetFinalOperator(this));
 }
        public override bool ReturnOperator(ref TICInstruction _instruction, List <CToken> tokenlist)
        {
            OPERAND op;

            if (tblfunction.IsStandard)
            {
                // _instruction.Operator.ReturnType = tokenlist[0].GetTokenPinType();
                _instruction.Operator.ReturnType = this.OverloadedType;
                for (int i = 0; i < tblvariable.m_tblFInstanceVariableList.Count; i++)
                {
                    if (tblvariable.m_tblFInstanceVariableList[i].Class == (int)(VarClass.Output | VarClass.FunctionInstanse))
                    {
                        op       = new OPERAND();
                        op.Index = tblvariable.m_tblFInstanceVariableList[i].VarNameID;
                        op.Token = (byte)Token_Type.Token_FBDPin;
                        op.type  = _instruction.Operator.ReturnType;
                        //tblvariable.Type = _instruction.Operator.ReturnType;
                        op.PropertyNo = 0;
                        //op.type = _instruction.Operator.ReturnType;
                        _instruction.OperandList.Add(op);
                        break;
                    }
                }
                _instruction.Operator.NoOfArg = 1;
                for (int i = 0; i < tokenlist.Count; i++)
                {
                    _instruction.OperandList.Add(GetFinalOperator(tokenlist[i]));
                    _instruction.Operator.NoOfArg++;
                }
                if (tblfunction.Overloaded)
                {
                    switch (tblfunction.FunctionName.ToLower())
                    {
                        #region Selection


                        #region max
                    case "max":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_MAX_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_MAX_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_MAX_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_MAX_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_MAX_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_MAX_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_MAX_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_MAX_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_MAX_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_MAX_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_MAX_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_MAX_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region min
                    case "min":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_MIN_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_MIN_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode  = (int)OPCODES.WORD_MIN_WORD_WORD;
                            _instruction.Operator.NoOfArg = m_NoOfFunctionArguments;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_MIN_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_MIN_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_MIN_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_MIN_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_MIN_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_MIN_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_MIN_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_MIN_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_MIN_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #region mux
                    case "mux":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_MUX_USINT_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_MUX_USINT_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_MUX_USINT_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_MUX_USINT_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_MUX_USINT_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode  = (int)OPCODES.INT_MUX_USINT_INT_INT;
                            _instruction.Operator.NoOfArg = 3;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_MUX_USINT_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_MUX_USINT_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_MUX_USINT_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_MUX_USINT_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_MUX_USINT_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_MUX_USINT_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #endregion

                        #region Comparision
                        #region ge
                    case "ge":
                    {
                        switch ((VarType)ReturnType(tokenlist))
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GE_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region gt
                    case "gt":
                    {
                        switch ((VarType)ReturnType(tokenlist))
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_GT_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region eq
                    case "eq":
                    {
                        switch ((VarType)ReturnType(tokenlist))
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_EQ_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region le
                    case "le":
                    {
                        switch ((VarType)ReturnType(tokenlist))
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LE_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region lt
                    case "lt":
                    {
                        switch ((VarType)ReturnType(tokenlist))
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LT_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #endregion

                        #region Arithmetic

                        #region mul
                    case "mul":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_MUL_SINT_SINT;

                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_MUL_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_MUL_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_MUL_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_MUL_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_MUL_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_MUL_REAL_REAL;
                            break;

                        case VarType.TIME:
                            switch ((VarType)tokenlist[1].GetTokenPinType())
                            {
                            case VarType.SINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_SINT;
                                break;

                            case VarType.INT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_INT;
                                break;

                            case VarType.DINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_DINT;
                                break;

                            case VarType.USINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_USINT;
                                break;

                            case VarType.UINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_UINT;
                                break;

                            case VarType.UDINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_UDINT;
                                break;

                            case VarType.REAL:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_MUL_TIME_REAL;
                                break;
                            }
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #region add
                    case "add":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_ADD_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_ADD_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_ADD_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_ADD_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_ADD_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_ADD_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_ADD_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_ADD_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion
                        #endregion
                        #region Bitwise

                        #region and
                    case "and":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_AND_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_AND_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_AND_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_AND_DWORD_DWORD;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region or
                    case "or":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_OR_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_OR_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_OR_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_OR_DWORD_DWORD;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region xor
                    case "xor":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_XOR_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_XOR_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_XOR_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_XOR_DWORD_DWORD;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #endregion
                    }
                }
                else  // non overloaded function
                {
                    switch (tblfunction.FunctionName.ToLower())
                    {
                    case "bools2dint":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.BOOLS_TO_DINT;
                        return(true);
                    }
                    }
                }
            }
            else  // user defined function
            {
            }
            _instruction.Operator.OpCode = (int)OPCODES.UNKNOWN;

            return(true);
            //-----------------------------------------------------------------------------
        }
Esempio n. 3
0
        public void loadDrawExpressionCollection(byte[] _compiledexp)
        {
            int size  = 0;
            int size1 = 0;
            //drawexpressionCollection = new DrawExpressionCollection(this);
            DrawExpressionCollectionCode drawexpressioncollectioncode = new DrawExpressionCollectionCode();

            drawexpressioncollectioncode = (DrawExpressionCollectionCode)RawDeserialize(_compiledexp, 0, typeof(DrawExpressionCollectionCode));
            size = Marshal.SizeOf(drawexpressioncollectioncode);
            if (drawexpressioncollectioncode.IsValid == 1)
            {
                for (int i = 0; i < drawexpressioncollectioncode.NoOfDynamicProperties; i++)
                {
                    ExpressionCode expressioncode = new ExpressionCode();
                    expressioncode = (ExpressionCode)RawDeserialize(_compiledexp, size, typeof(ExpressionCode));
                    size          += Marshal.SizeOf(expressioncode);

                    DisplayObjectDynamicProperty displayobjectdynamicproperty = new DisplayObjectDynamicProperty();
                    displayobjectdynamicproperty.ObjectType = (enumDynamicGraphicalProperty)expressioncode.Property;
                    displayobjectdynamicproperty.Type       = (VarType)expressioncode.ReturnType;
                    //displayobjectdynamicproperty.IsValid = 1;
                    displayobjectdynamicproperty.IsColor  = Convert.ToBoolean(expressioncode.IsColor);
                    displayobjectdynamicproperty.IsString = Convert.ToBoolean(expressioncode.IsString);

                    for (int j = 0; j < expressioncode.NoOfConditions; j++)
                    {
                        ConditionCode conditioncode = new ConditionCode();
                        //conditioncode.StrValue = new STRINGOBJ();
                        conditioncode = (ConditionCode)RawDeserialize(_compiledexp, size, typeof(ConditionCode));
                        size         += Marshal.SizeOf(conditioncode);
                        DisplayObjectDynamicPropertyCondition displayobjectdynamicpropertycondition = new DisplayObjectDynamicPropertyCondition();
                        displayobjectdynamicpropertycondition.IsValid = true;
                        displayobjectdynamicpropertycondition.m_Value = conditioncode.Value;
                        //unsafe
                        {
                            displayobjectdynamicpropertycondition.ToCopySTRINGOBJ(conditioncode.StrValue);

                            //for (int k = 0; k < 16; k++)
                            //{
                            //    displayobjectdynamicpropertycondition.m_StrValue.Val[k] = conditioncode.Val[k];
                            //}
                        }
                        size1 = 0;
                        {
                            OPERATION _operation = new OPERATION();
                            _operation = (OPERATION)RawDeserialize(_compiledexp, size, typeof(OPERATION));

                            size1 = Marshal.SizeOf(_operation);
                            size += Marshal.SizeOf(_operation);
                            while (size1 < _operation.Size1)
                            {
                                TICInstruction instruction = new TICInstruction();
                                instruction.Operator = (OPERATOR)RawDeserialize(_compiledexp, size, typeof(OPERATOR));
                                size  += Marshal.SizeOf(instruction.Operator);
                                size1 += Marshal.SizeOf(instruction.Operator);
                                for (int k = 0; k < instruction.Operator.NoOfArg; k++)
                                {
                                    OPERAND operand = new OPERAND();
                                    operand = (OPERAND)RawDeserialize(_compiledexp, size, typeof(OPERAND));
                                    size   += Marshal.SizeOf(operand);
                                    size1  += Marshal.SizeOf(operand);
                                    instruction.OperandList.Add(operand);
                                }
                                displayobjectdynamicpropertycondition.SimpleOperation.instructionlist.Add(instruction);
                            }
                        }
                        displayobjectdynamicproperty.ConditionList.Add(displayobjectdynamicpropertycondition);
                    }
                    drawexpressionCollection.objDisplayObjectDynamicPropertys.list.Add(displayobjectdynamicproperty);
                }
            }
        }
Esempio n. 4
0
        public override bool ReturnOperator(ref TICInstruction _instruction, List <CToken> tokenlist)
        {
            OPERAND op = new OPERAND();

            //CToken tok;
            op.Index = this.tblvariable.VarNameID;
            _instruction.OperandList.Add(op);
            _instruction.Operator.NoOfArg = 1;

            if (!tblfunction.IsStandard)
            {
                op            = new OPERAND();
                op.Token      = (byte)Token_Type.Token_FBID;
                op.type       = (int)VarType.ULINT;
                op.Index      = tblfunction.UDPouID;
                op.PropertyNo = 0;
                //op.type = _instruction.Operator.ReturnType;
                _instruction.OperandList.Add(op);

                _instruction.Operator.NoOfArg++;
            }


            for (int i = 0; i < tokenlist.Count; i++)
            {
                _instruction.OperandList.Add(GetFinalOperator(tokenlist[i]));
                _instruction.Operator.NoOfArg++;
            }
            //_instruction.Operator.NoOfArg = (byte)(tokenlist.Count+1);
            switch (tblfunction.FunctionName.ToLower())
            {
            case "alarmanc":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_ALARMANC;
                break;

            case "blink":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_BLINK;
                break;

            case "cmp":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_CMP;
                break;

            case "ctd":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_CTD;
                break;

            case "ctu":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_CTU;
                break;

            case "ctud":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_CTUD;
                break;

            case "derivative":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_DERIVATIVE;
                break;

            case "f_trig":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_F_TRIG;
                break;

            case "hysteresis":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_HYSTERESIS;
                break;

            case "integral":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_INTEGRAL;
                break;

            case "lag":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_LAG;
                break;

            case "pid":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_PID;
                break;

            case "pidcas":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_PIDCAS;
                break;

            case "pidovr":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_PIDOVR;
                break;

            case "r_trig":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_R_TRIG;
                break;

            case "ramp":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_RAMP;
                break;

            case "rs":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_RS;
                break;

            case "rtc":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_RTC;
                break;

            case "selpri":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SELPRI;
                break;

            case "selread":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SELREAD;
                break;

            case "sema":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SEMA;
                break;

            case "setpri":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SETPRI;
                break;

            case "sig_gen":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SIG_GEN;
                break;

            case "split":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SPLIT;
                break;

            case "sr":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SR;
                break;

            case "stackin":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_STACKIN;
                break;

            case "swdout":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SWDOUT;
                break;

            case "swsout":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_SWSOUT;
                break;

            case "tof":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TOF;
                break;

            case "ton":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TON;
                break;

            case "tp":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TP;
                break;

            case "tpls":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TPLS;
                break;

            case "tstp":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TSTP;
                break;

            case "wkhour":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_WKHOUR;
                break;

            case "totalizer":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_TOTALIZER;
                break;

            case "ramp_gen":
                _instruction.Operator.OpCode = (int)OPCODES.FBD_CALL_RAMP_GEN;
                break;

            default:
                _instruction.Operator.OpCode = (int)OPCODES.CALLFB;
                break;
            }



            return(true);
            //-----------------------------------------------------------------------------
        }
Esempio n. 5
0
 public virtual bool ReturnOperator(ref TICInstruction _instruction, List <CToken> operandlist)
 {
     return(true);
 }
Esempio n. 6
0
        public override bool ReturnOperator(ref TICInstruction _instruction, List <CToken> tokenlist)
        {
            OPERAND op;

            if (tblfunction.IsStandard)
            {
                _instruction.Operator.ReturnType = this.OverloadedType;
                op            = new OPERAND();
                op.Token      = (byte)Token_Type.Token_TempValue;
                op.type       = _instruction.Operator.ReturnType;
                op.Index      = Compiler.GetUnassignedTempVar(op.type);
                op.PropertyNo = 0;
                //op.type = _instruction.Operator.ReturnType;
                _instruction.OperandList.Add(op);

                _instruction.Operator.NoOfArg = 1;
                for (int i = 0; i < tokenlist.Count; i++)
                {
                    _instruction.OperandList.Add(GetFinalOperator(tokenlist[i]));
                    _instruction.Operator.NoOfArg++;
                }
                if (tblfunction.Overloaded)
                {
                    switch (tblfunction.FunctionName.ToLower())
                    {
                        #region Numerical
                        #region abs

                    case "abs":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_ABS_SINT;

                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_ABS_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_ABS_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_ABS_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_ABS_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_ABS_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_ABS_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region sqrt
                    case "sqrt":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_SQRT_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region ln
                    case "ln":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_LN_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region log
                    case "log":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_LOG_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region exp
                    case "exp":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_EXP_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region sin
                    case "sin":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_SIN_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region cos
                    case "cos":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_COS_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region tan
                    case "tan":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_TAN_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #region asin
                    case "asin":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_ASIN_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #region acos
                    case "acos":
                    {
                        switch ((VarType)tokenlist[0].GetTokenPinType())
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_ACOS_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region atan
                    case "atan":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_ATAN_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #endregion

                        #region Bit-shift
                        #region shl
                    case "shl":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_SHL_BYTE_UINT;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_SHL_WORD_UINT;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_SHL_DWORD_UINT;
                            break;
                        }

                        return(true);
                    }
                        #endregion

                        #region shr
                    case "shr":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_SHR_BYTE_UINT;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_SHR_WORD_UINT;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_SHR_DWORD_UINT;
                            break;
                        }

                        return(true);
                    }
                        #endregion

                        #region ror
                    case "ror":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_ROR_BYTE_UINT;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_ROR_WORD_UINT;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_ROR_DWORD_UINT;
                            break;
                        }

                        return(true);
                    }
                        #endregion

                        #region rol
                    case "rol":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_ROL_BYTE_UINT;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_ROL_WORD_UINT;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_ROL_DWORD_UINT;
                            break;
                        }

                        return(true);
                    }
                        #endregion

                        #endregion


                        #region Selection
                        #region sel
                    case "sel":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_SEL_BOOL_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_SEL_BOOL_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_SEL_BOOL_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_SEL_BOOL_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_SEL_BOOL_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_SEL_BOOL_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_SEL_BOOL_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_SEL_BOOL_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_SEL_BOOL_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_SEL_BOOL_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_SEL_BOOL_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_SEL_BOOL_TIME_TIME;
                            break;

                        default:
                            return(false);
                        }
                        return(true);
                    }
                        #endregion


                        #region limit
                    case "limit":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_LIMIT_BOOL_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_LIMIT_BYTE_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_LIMIT_WORD_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_LIMIT_DWORD_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_LIMIT_SINT_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_LIMIT_INT_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_LIMIT_DINT_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_LIMIT_USINT_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_LIMIT_UINT_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_LIMIT_UDINT_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_LIMIT_REAL_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.LREAL_LIMIT_LREAL_LREAL_LREAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #endregion

                        #region Comparision



                        #region ne
                    case "ne":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_BOOL_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_BYTE_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_WORD_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_DWORD_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NE_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #endregion

                        #region Arithmetic


                        #region div
                    case "div":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_DIV_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_DIV_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_DIV_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_DIV_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_DIV_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_DIV_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_DIV_REAL_REAL;
                            break;

                        case VarType.TIME:
                            switch ((VarType)tokenlist[1].GetTokenPinType())
                            {
                            case VarType.SINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_SINT;
                                break;

                            case VarType.INT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_INT;
                                break;

                            case VarType.DINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_DINT;
                                break;

                            case VarType.USINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_USINT;
                                break;

                            case VarType.UINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_UINT;
                                break;

                            case VarType.UDINT:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_UDINT;
                                break;

                            case VarType.REAL:
                                _instruction.Operator.OpCode = (int)OPCODES.TIME_DIV_TIME_REAL;
                                break;
                            }
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #region sub
                    case "sub":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_SUB_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_SUB_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_SUB_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_SUB_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_SUB_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_SUB_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_SUB_REAL_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_SUB_TIME_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region mod
                    case "mod":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_MOD_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_MOD_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_MOD_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_MOD_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_MOD_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_MOD_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_MOD_REAL_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region EXPT
                    case "expt":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_EXPT_SINT_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_EXPT_INT_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_EXPT_DINT_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_EXPT_USINT_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_EXPT_UINT_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_EXPT_UDINT_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_EXPT_REAL_REAL;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #region move
                    case "move":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_TO_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_TO_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_TO_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_TO_DWORD;
                            break;

                        case VarType.SINT:
                            _instruction.Operator.OpCode = (int)OPCODES.SINT_TO_SINT;
                            break;

                        case VarType.INT:
                            _instruction.Operator.OpCode = (int)OPCODES.INT_TO_INT;
                            break;

                        case VarType.DINT:
                            _instruction.Operator.OpCode = (int)OPCODES.DINT_TO_DINT;
                            break;

                        case VarType.USINT:
                            _instruction.Operator.OpCode = (int)OPCODES.USINT_TO_USINT;
                            break;

                        case VarType.UINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UINT_TO_UINT;
                            break;

                        case VarType.UDINT:
                            _instruction.Operator.OpCode = (int)OPCODES.UDINT_TO_UDINT;
                            break;

                        case VarType.REAL:
                            _instruction.Operator.OpCode = (int)OPCODES.REAL_TO_REAL;
                            break;

                        case VarType.TIME:
                            _instruction.Operator.OpCode = (int)OPCODES.TIME_TO_TIME;
                            break;
                        }
                        return(true);
                    }
                        #endregion

                        #endregion

                        #region Bitwise



                        #region not
                    case "not":
                    {
                        switch ((VarType)_instruction.Operator.ReturnType)
                        {
                        case VarType.BOOL:
                            _instruction.Operator.OpCode = (int)OPCODES.BOOL_NOT_BOOL;
                            break;

                        case VarType.BYTE:
                            _instruction.Operator.OpCode = (int)OPCODES.BYTE_NOT_BYTE;
                            break;

                        case VarType.WORD:
                            _instruction.Operator.OpCode = (int)OPCODES.WORD_NOT_WORD;
                            break;

                        case VarType.DWORD:
                            _instruction.Operator.OpCode = (int)OPCODES.DWORD_NOT_DWORD;
                            break;
                        }
                        return(true);
                    }
                        #endregion


                        #endregion
                    }
                }
                else
                {
                    switch (tblfunction.FunctionName.ToLower())
                    {
                        #region ENUM_KTC_DEFINED

                        #region rgb
                    case "rgb":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.UDINT_RGB_DINT_DINT_DINT;
                        return(true);
                    }

                        #endregion

                        #region formated

                    case "formated":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.FORMATED_STRING_REAL_UINT;
                        return(true);
                    }


                        #endregion

                        #region time
                    case "sub_time":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.TIME_SUB_TIME_TIME;
                        return(true);
                    }

                    case "getlocalyear":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETYEAR_DINT;

                        return(true);
                    }

                    case "getlocalmonth":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETMONTH_DINT;

                        return(true);
                    }

                    case "getlocalday":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETDAY_DINT;
                        return(true);
                    }

                    case "getlocalhour":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETHOUR_DINT;
                        return(true);
                    }

                    case "getlocalminute":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETMINUTE_DINT;
                        return(true);
                    }

                    case "getlocalsecond":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETSECOND_DINT;
                        return(true);
                    }

                    case "getlocalmilisecond":
                    {
                        _instruction.Operator.OpCode = (int)OPCODES.DINT_GETMILLSECOND_DINT;
                        return(true);
                    }
                        #endregion

                        #endregion
                    }
                }
            }
            else
            {
                _instruction.Operator.ReturnType = tblfunction.GetReturnType();
                _instruction.Operator.OpCode     = (int)OPCODES.CALLF;
                op            = new OPERAND();
                op.Token      = (byte)Token_Type.Token_TempValue;
                op.type       = _instruction.Operator.ReturnType;
                op.Index      = Compiler.GetUnassignedTempVar(op.type);
                op.PropertyNo = 0;
                //op.type = _instruction.Operator.ReturnType;
                _instruction.OperandList.Add(op);

                _instruction.Operator.NoOfArg = 1;

                op            = new OPERAND();
                op.Token      = (byte)Token_Type.Token_FBID;
                op.type       = (int)VarType.ULINT;
                op.Index      = tblfunction.UDPouID;
                op.PropertyNo = 0;
                //op.type = _instruction.Operator.ReturnType;
                _instruction.OperandList.Add(op);

                _instruction.Operator.NoOfArg++;

                for (int i = 0; i < tokenlist.Count; i++)
                {
                    _instruction.OperandList.Add(GetFinalOperator(tokenlist[i]));
                    _instruction.Operator.NoOfArg++;
                }
                return(true);
            }
            _instruction.Operator.OpCode = (int)OPCODES.UNKNOWN;

            return(true);
            //-----------------------------------------------------------------------------
        }