Ejemplo n.º 1
0
        public IValueRegister GetFormalParameterRegister(string name)
        {
            int index = Array.IndexOf(FormalParameters.Keys.ToArray(), name);
            ClepsType paramType = (ExpressionType as FunctionClepsType).ParameterTypes[index];

            JavaScriptRegister register = new JavaScriptRegister(FormalParameters[name], paramType);
            return register;
        }
Ejemplo n.º 2
0
        public IValueRegister CreateNewVariable(ClepsVariable variable, IValue initialValue = null)
        {
            string varName = NameGenerator.GetAvailableName(JavaScriptCodeParameters.VARIABLEPREFIX + variable.VariableName, variablesCreated);
            variablesCreated.Add(varName);

            if (initialValue == null)
            {
                AppendFormatLine("var {0};", varName);
            }
            else
            {
                AppendFormatLine("var {0} = {1};", varName, (initialValue as JavaScriptValue).Expression);
            }

            var ret = new JavaScriptRegister(varName, variable.VariableType);
            return ret;
        }
Ejemplo n.º 3
0
        public IValueRegister GetArrayElementRegister(IValue value, List<IValue> indexes)
        {
            JavaScriptValue valueToUse = value as JavaScriptValue;

            string code = String.Format("{0}{1}", valueToUse.Expression, String.Join("", indexes.Select(i => "[" + (i as JavaScriptValue).Expression + "]")));
            ClepsType returnType = (value.ExpressionType as ArrayClepsType).GetTypeForArrayAccess(indexes.Count);

            JavaScriptRegister ret = new JavaScriptRegister(code, returnType);
            return ret;
        }
Ejemplo n.º 4
0
 public IValueRegister GetConstantMemberFieldRegisterForWrite(string className, string memberName, ClepsType memberType)
 {
     JavaScriptRegister ret;
     if (memberType.IsFunctionType)
     {
         ret = new JavaScriptRegister(String.Format("{0}.{1}.prototype.{2}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, className, JavaScriptCodeParameters.GetMangledFunctionName(memberName, memberType as FunctionClepsType)), memberType);
     }
     else
     {
         ret = new JavaScriptRegister(String.Format("{0}.{1}.prototype.{2}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, className, memberName), memberType);
     }
     return ret;
 }
Ejemplo n.º 5
0
 public IValueRegister GetMemberFieldRegisterFromSameClass(string className, string memberName, ClepsType memberType)
 {
     var ret = new JavaScriptRegister("this." + memberName, memberType);
     return ret;
 }
Ejemplo n.º 6
0
        public IValueRegister GetMemberFieldRegisterFromSameClass(string className, string memberName, ClepsType memberType)
        {
            var ret = new JavaScriptRegister("this." + memberName, memberType);

            return(ret);
        }