Ejemplo n.º 1
0
        public void LoadAssignmentsFromContent(string path)
        {
            var content     = this.GetContentFor(path);
            var lang        = LanguageSupport.DetectLanguage(path);
            var assignments = InspectorSupport.ParseAssigments(content, lang);

            foreach (var entry in assignments)
            {
                try
                {
                    var ofs = this.Map.ResolveEndOffset(entry.Key, path);
                    this.Emulator.AddAssigment(ofs, entry.Value.name, entry.Value.type);
                }
                catch
                {
                    continue;
                }
            }
        }
        public bool CompileContract(string sourceCode, SourceLanguage language, string outputFile = null)
        {
            Compiler compiler = new Compiler(_settings);

            compiler.SendToLog += Compiler_SendToLog;

            var extension = LanguageSupport.GetExtension(language);

            var sourceFile = TempContractName + extension;

            Directory.CreateDirectory(_settings.path);
            var fileName = Path.Combine(_settings.path, sourceFile);

            var avmPath = fileName.Replace(extension, ".avm");

            try
            {
                File.Delete(avmPath.Replace(".avm", ".abi.json"));
                File.Delete(avmPath.Replace(".avm", ".debug.json"));
            }
            catch
            {
                // ignore
            }

            bool success = compiler.CompileContract(sourceCode, fileName, language);

            if (success)
            {
                _avmFilePath = avmPath;

                if (outputFile != null)
                {
                    File.Copy(_avmFilePath, outputFile, true);
                }
            }

            _isCompiled = success;
            return(success);
        }
Ejemplo n.º 3
0
        public bool CompileContract(string sourceCode, SourceLanguage language, string outputFile = null)
        {
            Compiler compiler = new Compiler(Settings);

            compiler.SendToLog += Compiler_SendToLog;

            var extension = LanguageSupport.GetExtension(language);

            var sourceFile = TempContractName + extension;

            string fileName;

            if (outputFile == null)
            {
                Directory.CreateDirectory(Settings.path);
                fileName = Path.Combine(Settings.path, sourceFile);
            }
            else
            {
                fileName = outputFile.Replace(".avm", extension);
            }

            var avmPath = fileName.Replace(extension, ".avm");

            string abiFile      = avmPath.Replace(".avm", ".abi.json");
            string debugMapFile = avmPath.Replace(".avm", ".debug.json");

            try
            {
                File.Delete(abiFile);
                File.Delete(debugMapFile);
            }
            catch
            {
                // ignore
            }

            bool success = compiler.CompileContract(sourceCode, fileName, language);

            if (success)
            {
                _avmFilePath = avmPath;

                /*if (outputFile != null)
                 * {
                 *  File.Copy(_avmFilePath, outputFile, true);
                 *
                 *  if (File.Exists(abiFile))
                 *  {
                 *      File.Copy(abiFile, outputFile.Replace(".avm", ".abi.json"), true);
                 *  }
                 *
                 *  if (File.Exists(debugMapFile))
                 *  {
                 *      File.Copy(debugMapFile, outputFile.Replace(".avm", ".debug.json"), true);
                 *  }
                 * }*/
            }

            _isCompiled = success;
            return(success);
        }