public IValue GetRegisterValue(IValueRegister register)
 {
     JavaScriptRegister registerToUse = register as JavaScriptRegister;
     var ret = new JavaScriptValue(registerToUse.Expression, registerToUse.ExpressionType);
     return ret;
 }
        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;
        }
 public IValue GetThisInstanceValue(BasicClepsType thisInstanceType)
 {
     JavaScriptValue ret = new JavaScriptValue("this", thisInstanceType);
     return ret;
 }
        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;
        }
 public IValue GetClassStaticInstance(BasicStaticClepsType clepsClass)
 {
     JavaScriptValue ret = new JavaScriptValue(TOPLEVELNAMESPACE + "." + clepsClass.RawTypeName + "Inst", clepsClass);
     return ret;
 }
        public IValue GetAreByteValuesEqual(IValue leftValue, IValue rightValue)
        {
            JavaScriptValue leftValueToUse = leftValue as JavaScriptValue;
            JavaScriptValue rightValueToUse = rightValue as JavaScriptValue;

            string code = String.Format("({0} == {1})", leftValueToUse.Expression, rightValueToUse.Expression);

            JavaScriptValue ret = new JavaScriptValue(code, CompilerConstants.ClepsBoolType);
            return ret;
        }
        public IValue GetFunctionCallReturnValue(string fullyQualifiedClassName, string targetFunctionName, FunctionClepsType clepsType, List<IValue> parameters)
        {
            string parameterString = String.Join(", ", parameters.Select(v => (v as JavaScriptValue).Expression).ToList());
            string code = String.Format("{0}.{1}.{2}({3})", TOPLEVELNAMESPACE, fullyQualifiedClassName, targetFunctionName, parameterString);

            JavaScriptValue ret = new JavaScriptValue(code, clepsType.ReturnType);
            return ret;
        }