Esempio n. 1
0
        public IValue GetFunctionCallReturnValue(IValue target, BasicClepsType targetType, string targetFunctionName, FunctionClepsType clepsType, List<IValue> parameters)
        {
            string code;

            if (CompilerConstants.SystemSupportedTypes.Contains(targetType) && target != null)
            {
                string fullFunctionName = String.Format("{0}.{1}.prototype.{2}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, targetType.GetClepsTypeString(), JavaScriptCodeParameters.GetMangledFunctionName(targetFunctionName, clepsType));
                string functionTarget = target != null ? (target as JavaScriptValue).Expression : String.Format("{0}.{1}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, targetType.GetClepsTypeString());
                string parameterString = String.Join("", parameters.Select(v => ", " + (v as JavaScriptValue).Expression).ToList());

                code = String.Format("{0}.call({1}{2})", fullFunctionName, functionTarget, parameterString);
            }
            else
            {
                string functionTarget = target != null ? (target as JavaScriptValue).Expression : String.Format("{0}.{1}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, targetType.GetClepsTypeString());
                string fullFunctionName = String.Format("{0}.{1}", functionTarget, JavaScriptCodeParameters.GetMangledFunctionName(targetFunctionName, clepsType));

                string parameterString = String.Join(", ", parameters.Select(v => (v as JavaScriptValue).Expression).ToList());
                code = String.Format("{0}({1})", fullFunctionName, parameterString);
            }

            JavaScriptValue ret = new JavaScriptValue(code, clepsType.ReturnType);
            return ret;
        }
Esempio n. 2
0
        public IValue CreateClassInstance(BasicClepsType instanceType, List<IValue> parameters)
        {
            string parameterString = String.Join(", ", parameters.Select(v => (v as JavaScriptValue).Expression).ToList());
            string code = String.Format("new {0}.{1}({2})", JavaScriptCodeParameters.TOPLEVELNAMESPACE, instanceType.GetClepsTypeString(), parameterString);

            JavaScriptValue ret = new JavaScriptValue(code, instanceType);
            return ret;
        }