public IMethodRegister CreateMethod(string className, bool isStatic, ClepsType functionType, string functionName) { if (!classesLoaded.ContainsKey(className)) { throw new ArgumentException(String.Format("Class {0} not loaded", className)); } if (!functionType.IsFunctionType) { throw new ArgumentException("Expected function type. Got " + functionType.GetClepsTypeString()); } var classNameToUse = isStatic ? className + ".static" : className; var functionNameAndType = new FunctionNameAndType(classNameToUse, functionName, functionType); var methodList = isStatic ? staticMethods[classNameToUse] : memberMethods[classNameToUse]; if (methodList.Contains(functionNameAndType)) { throw new ArgumentException(String.Format("Function {0} {1} {2} for class {3} already exists", isStatic ? "static" : "", functionType, functionName, className)); } methodList.Add(functionNameAndType); var methodRegister = new JavaScriptMethod(functionType as FunctionClepsType); methodBodies.Add(functionNameAndType, methodRegister); return methodRegister; }
public IMethodRegister CreateMethod(string className, bool isStatic, ClepsType functionType, string functionName) { if (!classesLoaded.ContainsKey(className)) { throw new ArgumentException(String.Format("Class {0} not loaded", className)); } if (!functionType.IsFunctionType) { throw new ArgumentException("Expected function type. Got " + functionType.GetClepsTypeString()); } var classNameToUse = isStatic ? className + ".static" : className; var functionNameAndType = new FunctionNameAndType(classNameToUse, functionName, functionType); var methodList = isStatic ? staticMethods[classNameToUse] : memberMethods[classNameToUse]; if (methodList.Contains(functionNameAndType)) { throw new ArgumentException(String.Format("Function {0} {1} {2} for class {3} already exists", isStatic ? "static" : "", functionType, functionName, className)); } methodList.Add(functionNameAndType); var methodRegister = new JavaScriptMethod(functionType as FunctionClepsType); methodBodies.Add(functionNameAndType, methodRegister); return(methodRegister); }
public void CreateClass(string className) { ClassesLoaded.Add(className, null); ClassInitializers[className] = new JavaScriptMethod(new FunctionClepsType(new List<ClepsType>(), VoidClepsType.GetVoidType())); ClassStaticInitializers[className] = new JavaScriptMethod(new FunctionClepsType(new List<ClepsType>(), VoidClepsType.GetVoidType())); //static initializing should occur only once ClassStaticInitializers[className].CreateIfStatementBlock(new JavaScriptValue("![" + JavaScriptCodeParameters.TOPLEVELNAMESPACE + "." + className + ".classStaticInitialized]", CompilerConstants.ClepsBoolType)); ClassStaticInitializers[className].CreateAssignment(new JavaScriptRegister(JavaScriptCodeParameters.TOPLEVELNAMESPACE + "." + className + ".classStaticInitialized", CompilerConstants.ClepsBoolType), new JavaScriptValue("[true]", CompilerConstants.ClepsBoolType)); }
public void CreateClass(string className) { ClassesLoaded.Add(className, null); ClassInitializers[className] = new JavaScriptMethod(new FunctionClepsType(new List <ClepsType>(), VoidClepsType.GetVoidType())); ClassStaticInitializers[className] = new JavaScriptMethod(new FunctionClepsType(new List <ClepsType>(), VoidClepsType.GetVoidType())); //static initializing should occur only once ClassStaticInitializers[className].CreateIfStatementBlock(new JavaScriptValue("![" + JavaScriptCodeParameters.TOPLEVELNAMESPACE + "." + className + ".classStaticInitialized]", CompilerConstants.ClepsBoolType)); ClassStaticInitializers[className].CreateAssignment(new JavaScriptRegister(JavaScriptCodeParameters.TOPLEVELNAMESPACE + "." + className + ".classStaticInitialized", CompilerConstants.ClepsBoolType), new JavaScriptValue("[true]", CompilerConstants.ClepsBoolType)); }
public void Initiate() { FunctionClepsType voidFuncType = new FunctionClepsType(new List<ClepsType>(), VoidClepsType.GetVoidType()); ClassesLoaded = new Dictionary<string, ClepsClass>(); ClassInitializers = new Dictionary<string, JavaScriptMethod>(); ClassStaticInitializers = new Dictionary<string, JavaScriptMethod>(); GlobalInitializer = new JavaScriptMethod(voidFuncType); EntryPointClass = null; EntryPointFunctionName = null; GlobalNativeCodeSnippets = new List<string>(); }
public void Initiate() { FunctionClepsType voidFuncType = new FunctionClepsType(new List <ClepsType>(), VoidClepsType.GetVoidType()); ClassesLoaded = new Dictionary <string, ClepsClass>(); ClassInitializers = new Dictionary <string, JavaScriptMethod>(); ClassStaticInitializers = new Dictionary <string, JavaScriptMethod>(); GlobalInitializer = new JavaScriptMethod(voidFuncType); EntryPointClass = null; EntryPointFunctionName = null; GlobalNativeCodeSnippets = new List <string>(); }
public JavaScriptCodeOutputter(Dictionary<string, ClepsClass> classesLoaded, Dictionary<string, JavaScriptMethod> classInitializers, Dictionary<string, JavaScriptMethod> classStaticInitializers, JavaScriptMethod globalInitializer, string entryPointClass, string entryPointFunctionName, List<string> globalNativeCodeSnippets ) { ClassesLoaded = classesLoaded; ClassInitializers = classInitializers; ClassStaticInitializers = classStaticInitializers; GlobalInitializer = globalInitializer; EntryPointClass = entryPointClass; EntryPointFunctionName = entryPointFunctionName; GlobalNativeCodeSnippets = globalNativeCodeSnippets; NamespacesCreated = new List<string>(); }
public JavaScriptCodeOutputter(Dictionary <string, ClepsClass> classesLoaded, Dictionary <string, JavaScriptMethod> classInitializers, Dictionary <string, JavaScriptMethod> classStaticInitializers, JavaScriptMethod globalInitializer, string entryPointClass, string entryPointFunctionName, List <string> globalNativeCodeSnippets ) { ClassesLoaded = classesLoaded; ClassInitializers = classInitializers; ClassStaticInitializers = classStaticInitializers; GlobalInitializer = globalInitializer; EntryPointClass = entryPointClass; EntryPointFunctionName = entryPointFunctionName; GlobalNativeCodeSnippets = globalNativeCodeSnippets; NamespacesCreated = new List <string>(); }
public IMethodValue CreateNewMethod(FunctionClepsType functionType) { var methodRegister = new JavaScriptMethod(functionType); return methodRegister; }
private void GenerateMethodWithBody(StringBuilder output, string fullyQualifiedClassName, string methodName, FunctionClepsType methodType, bool isStatic, JavaScriptMethod method) { string fullFunctionName = String.Format("{0}.{1}.{2}{3}", JavaScriptCodeParameters.TOPLEVELNAMESPACE, fullyQualifiedClassName, isStatic ? "" : "prototype.", JavaScriptCodeParameters.GetMangledFunctionName(methodName, methodType) ); output.AppendFormat("{0} = {1};\n", fullFunctionName, method.GetMethodText() ); }
public IMethodValue CreateNewMethod(FunctionClepsType functionType) { var methodRegister = new JavaScriptMethod(functionType); return(methodRegister); }