public static void WriteLn(L1Array<int> str) { string s = L1Runtime.GetStringFromArray(str); Console.WriteLine(s); }
public static L1Array<int> StrCat(L1Array<int> str1, L1Array<int> str2) { string s1 = L1Runtime.GetStringFromArray(str1); string s2 = L1Runtime.GetStringFromArray(str2); return L1Runtime.GetArrayFromString(s1 + s2); }
public static L1Array<int> GetArrayFromString(string str) { L1Array<int> array = new L1Array<int>(str.Length); for (int i = 0; i < str.Length; ++i) array.SetValue(i, Convert.ToInt32(str[i])); return array; }
public static L1Array<int> GetArrayFromObjectArray(object[] a) { L1Array<int> array = new L1Array<int>(a.Length); for (int i = 0; i < a.Length; ++i) array.SetValue(i, Convert.ToInt32(a[i])); return array; }
public static void L1Main(string[] args) { Type program = null; Assembly[] asm = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly a in asm) { program = a.GetType("L1ProgramFunctions"); if (program != null) break; } MethodInfo mi = program.GetMethod("Main", new Type[] { typeof(int), typeof(L1Array<L1Array<int>>) }); if (mi == null) { Console.WriteLine("Missing method: Main(int, int array array)"); } else { L1Array<L1Array<int>> l1args = new L1Array<L1Array<int>>(args.Length); for (int i = 0; i < args.Length; ++i) { l1args.SetValue(i, GetArrayFromString(args[i])); } int code = (int)mi.Invoke(null, new object[] { args.Length, l1args }); Console.WriteLine(); Console.WriteLine("End program with code " + code); } }
public static string GetStringFromArray(L1Array<int> str) { int length = str.GetLength(); StringBuilder sb = new StringBuilder(length); for (int i = 0; i < length; ++i) { int c = str.GetValue(i); if (c == (char)0) break; sb.Append((char)c); } return sb.ToString(); }