This commit is contained in:
Бондарев Иван 2018-11-04 12:06:43 +01:00
parent 03dd4d0f46
commit 466ac552d8
5 changed files with 23 additions and 6 deletions

View file

@ -303,7 +303,16 @@ namespace PascalABCCompiler
this.source_context = sc;
}
}
public class DuplicateDirective : CompilerCompilationError
{
public string DirectiveName;
public DuplicateDirective(string FileName, string DirectiveName, SyntaxTree.SourceContext sc)
: base(string.Format(StringResources.Get("COMPILATIONERROR_DUPLICATE_DIRECTIVE{0}"), DirectiveName), FileName)
{
this.DirectiveName = DirectiveName;
this.source_context = sc;
}
}
public class UnitNotFound : CompilerCompilationError
{
public string UnitName;
@ -1076,18 +1085,20 @@ namespace PascalABCCompiler
}
}
private Dictionary<string,List<TreeRealization.compiler_directive>> GetCompilerDirectives(List<CompilationUnit> Units)
private Dictionary<string, List<TreeRealization.compiler_directive>> GetCompilerDirectives(List<CompilationUnit> Units)
{
Dictionary<string, List<TreeRealization.compiler_directive>> Directives = new Dictionary<string, List<TreeRealization.compiler_directive>>(StringComparer.CurrentCultureIgnoreCase);
for (int i = 0; i < Units.Count; i++)
{
TreeRealization.common_unit_node cun = Units[i].SemanticTree as TreeRealization.common_unit_node;
if (cun!=null)
if (cun != null)
foreach (TreeRealization.compiler_directive cd in cun.compiler_directives)
{
if(!Directives.ContainsKey(cd.name))
if (!Directives.ContainsKey(cd.name))
Directives.Add(cd.name, new List<TreeRealization.compiler_directive>());
else if (string.Compare(cd.name, "mainresource", true) == 0)
throw new DuplicateDirective(cd.location.doc.file_name, "mainresource", cd.location);
Directives[cd.name].Insert(0, cd);
}
}
@ -1850,7 +1861,6 @@ namespace PascalABCCompiler
TreeRealization.compiler_directive compilerDirective;
//TODO сделать это понормальному!!!!!
if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_apptype))
{
string directive = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_apptype][0].directive;

View file

@ -0,0 +1,4 @@
{$mainresource '0.res'}
{$mainresource '1.res'}
begin end.

View file

@ -13,6 +13,7 @@ UNDEFINED_SEMANTIC_ERROR{0}=Undefined semantic error : {0}
RESOURCEFILE_{0}_NOT_FOUND=Resource file '{0}' not found
DUPLICATE_USES_UNIT{0}=Duplicate identifier '{0}' in uses section
MAINRESOURCE_NOT_ALLOWED=mainresource can not be used with the directives: product, version, company, trademark
DUPLICATE_DIRECTIVE{0}=Duplicate directive {0}
%PREFIX%=
COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Internal compiler error in module {0} :'{1}'

View file

@ -13,6 +13,7 @@ UNDEFINED_SEMANTIC_ERROR{0}=Неопределенная семантическ
RESOURCEFILE_{0}_NOT_FOUND=Файл '{0}' не найден
DUPLICATE_USES_UNIT{0}=Повторное подключение модуля {0} в секции uses
MAINRESOURCE_NOT_ALLOWED=Недопустимо совместное использование директивы mainresource и директив product, version, company, trademark
DUPLICATE_DIRECTIVE{0}=Повторное объявление директивы {0}
%PREFIX%=
COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Внутренняя ошибка компилятора в модуле {0} :'{1}'

View file

@ -13,6 +13,7 @@ UNDEFINED_SEMANTIC_ERROR{0}=Невизначена семантична поми
RESOURCEFILE_{0}_NOT_FOUND=Файл '{0}' не знайдено
DUPLICATE_USES_UNIT{0}=Повторне підключення модуля {0} в секції uses
MAINRESOURCE_NOT_ALLOWED=Неприпустимо сумісне використання директиви mainresource і директив product, version, company, trademark
DUPLICATE_DIRECTIVE{0}=Повторное объявление директивы {0}
%PREFIX%=
COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Внутрішня помилка компілятора в модулі {0} :'{1}'