Esempio n. 1
0
        public AbstractPlatform GetPlatform(string name)
        {
            if (platforms == null)
            {
                platforms = new Dictionary <string, AbstractPlatform>();
                foreach (System.Reflection.Assembly assembly in GetRawAssemblies())
                {
                    AbstractPlatform platform = this.GetPlatformInstance(assembly);
                    platform.PlatformProvider = this;
                    string key = platform.Name.ToLowerInvariant();
                    if (platforms.ContainsKey(key))
                    {
                        throw new System.InvalidOperationException("Multiple platforms with the same ID: '" + key + "'");
                    }
                    platforms[key] = platform;
                }
            }

            if (name != null)
            {
                name = name.ToLowerInvariant();
                if (platforms.ContainsKey(name))
                {
                    return(platforms[name]);
                }
            }

            return(null);
        }
Esempio n. 2
0
        public string TranslateNativeInvocation(Token throwToken, AbstractPlatform translator, string functionName, object[] args)
        {
            if (this.translations == null)
            {
                string methodTranslations = this.ReadFile(System.IO.Path.Combine("methods", this.platformName + ".txt"), false);
                this.translations = new Dictionary <string, string>();
                foreach (string line in methodTranslations.Split('\n'))
                {
                    string[] parts = line.Trim().Split(':');
                    if (parts.Length > 1)
                    {
                        string key   = parts[0];
                        string value = parts[1];
                        for (int i = 2; i < parts.Length; ++i)
                        {
                            value += ":" + parts[i];
                        }
                        this.translations[key.Trim()] = value.Trim();
                    }
                }
            }

            if (this.translations.ContainsKey(functionName))
            {
                string output = this.translations[functionName];
                for (int i = 0; i < args.Length; ++i)
                {
                    string argAsString = translator.Translate(args[i]);
                    output = output.Replace("[ARG:" + (i + 1) + "]", argAsString);
                }
                return(output);
            }

            throw new ParserException(throwToken, "No native translation provided for " + functionName);
        }
Esempio n. 3
0
        private static void Compile(string[] args)
        {
            BuildContext     buildContext = Program.GetBuildContext(args);
            AbstractPlatform platform     = GetPlatformInstance(buildContext);

            platform.Compile(buildContext, buildContext.SourceFolder, buildContext.OutputFolder);
        }
 public LibraryResourceDatabase(Library library, AbstractPlatform platform)
 {
     this.library                 = library;
     this.exportEntities          = null;
     this.ApplicablePlatformNames = new HashSet <string>();
     while (platform != null)
     {
         this.ApplicablePlatformNames.Add(platform.Name);
         platform = platform.ParentPlatform;
     }
 }
Esempio n. 5
0
		public Parser(AbstractPlatform platform, BuildContext buildContext, SystemLibraryManager sysLibMan)
		{
			this.NullablePlatform = platform;
			this.IsTranslateMode = platform != null;
			this.CurrentClass = null;
			this.CurrentSystemLibrary = null;
			this.BuildContext = buildContext;
			this.VariableIds = new VariableIdAllocator();
			this.SystemLibraryManager = sysLibMan ?? new SystemLibraryManager();
			this.CurrentNamespace = "";
			this.NamespacePrefixLookupForCurrentFile = new List<string>();
		}
Esempio n. 6
0
 public Parser(AbstractPlatform platform, BuildContext buildContext, SystemLibraryManager sysLibMan)
 {
     this.NullablePlatform     = platform;
     this.IsTranslateMode      = platform != null;
     this.CurrentClass         = null;
     this.CurrentSystemLibrary = null;
     this.BuildContext         = buildContext;
     this.SystemLibraryManager = sysLibMan ?? new SystemLibraryManager();
     this.CurrentNamespace     = "";
     this.NamespacePrefixLookupForCurrentFile = new List <string>();
     this.ConstantAndEnumResolutionState      = new Dictionary <Executable, int>();
 }
Esempio n. 7
0
        public string GetLibrarySwitchStatement(AbstractPlatform platform)
        {
            List <string> output = new List <string>();

            foreach (string name in this.orderedListOfFunctionNames)
            {
                output.Add("case " + this.libFunctionIds[name] + ":\n");
                output.Add("$_comment('" + name + "');");
                output.Add(this.importedLibraries[this.functionNameToLibraryName[name]].GetTranslationCode(name));
                output.Add("\nbreak;\n");
            }
            if (this.orderedListOfFunctionNames.Count == 0)
            {
                output.Add("case 0: break;");
            }
            return(string.Join("\n", output));
        }
Esempio n. 8
0
		public InterpreterCompiler(AbstractPlatform platform, SystemLibraryManager sysLibMan)
		{
			this.platform = platform;
			this.interpreterParser = new Parser(platform, null, sysLibMan);
		}
Esempio n. 9
0
		internal ExpressionTranslator(AbstractPlatform platform)
		{
			this.platform = platform;
			this.Platform = platform.PlatformId;
			this.Language = platform.LanguageId;
		}
Esempio n. 10
0
 public InterpreterCompiler(AbstractPlatform platform, SystemLibraryManager sysLibMan)
 {
     this.platform          = platform;
     this.interpreterParser = new Parser(platform, null, sysLibMan);
 }