コード例 #1
0
        /*
         * @throws ConversionException
         */
        public ITES5Value CreateValue(ITES4Value value, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            ITES4Primitive primitive = value as ITES4Primitive;

            if (primitive != null)
            {
                return(TES5PrimitiveValueFactory.createValue(primitive));
            }
            ITES4Reference reference = value as ITES4Reference;

            if (reference != null)
            {
                return(this.referenceFactory.CreateReadReference(reference.StringValue, globalScope, multipleScriptsScope, codeScope.LocalScope));
            }
            ITES4Callable callable = value as ITES4Callable;

            if (callable != null)
            {
                return(this.CreateCodeChunk(callable, codeScope, globalScope, multipleScriptsScope));
            }
            ITES4BinaryExpression expression = value as ITES4BinaryExpression;

            if (expression != null)
            {
                return(this.ConvertExpression(expression, codeScope, globalScope, multipleScriptsScope));
            }
            throw new ConversionException("Unknown ITES4Value: " + value.GetType().FullName);
        }
        public static ITES5Primitive createValue(ITES4Primitive value)
        {
            TES4Type valueType = value.Type;
            object   valueData = value.Data;

            if (valueType == TES4Type.T_INT)
            {
                return(new TES5Integer((int)valueData));
            }
            else if (valueType == TES4Type.T_STRING)
            {
                return(new TES5String((string)valueData));
            }
            else if (valueType == TES4Type.T_FLOAT)
            {
                return(new TES5Float((float)valueData));
            }
            throw new ConversionException("Unknown value type to be factored from " + value.GetType().FullName);
        }