Skip to content

Commit

Permalink
Merge branch 'pascalabcnet:master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
spectatorBH authored Jan 5, 2024
2 parents f97caa0 + 4811924 commit 29dc93f
Show file tree
Hide file tree
Showing 78 changed files with 2,543 additions and 2,255 deletions.
2 changes: 1 addition & 1 deletion CodeCompletion/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CodeCompletion")]
[assembly: AssemblyCopyright("Copyright © 2005-2023 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyCopyright("Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
19 changes: 19 additions & 0 deletions Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,23 @@ void semanticTreeConvertersController_ChangeState(SemanticTreeConvertersControll
}
}

private static HashSet<string> knownDirectives = new HashSet<string>(new string[] { PascalABCCompiler.TreeConverter.compiler_string_consts.main_resource_string,
PascalABCCompiler.TreeConverter.compiler_string_consts.trademark_string, PascalABCCompiler.TreeConverter.compiler_string_consts.copyright_string,
PascalABCCompiler.TreeConverter.compiler_string_consts.company_string, PascalABCCompiler.TreeConverter.compiler_string_consts.product_string,
PascalABCCompiler.TreeConverter.compiler_string_consts.version_string, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_apptype,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_reference, PascalABCCompiler.TreeConverter.compiler_string_consts.include_namespace_directive,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_savepcu, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_zerobasedstrings,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_zerobasedstrings_ON, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_zerobasedstrings_OFF,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_nullbasedstrings_ON, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_nullbasedstrings_OFF,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_initstring_as_empty_ON, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_initstring_as_empty_OFF,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_resource, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_platformtarget,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_targetframework, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_faststrings,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_gendoc, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_region,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_endregion, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_ifdef,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_endif, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_ifndef,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_define, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_else,
PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_undef, PascalABCCompiler.TreeConverter.compiler_string_consts.compiler_directive_include});

private Dictionary<string, List<compiler_directive>> GetCompilerDirectives(List<CompilationUnit> Units)
{
Dictionary<string, List<compiler_directive>> directives = new Dictionary<string, List<compiler_directive>>(StringComparer.CurrentCultureIgnoreCase);
Expand All @@ -1170,6 +1187,8 @@ private Dictionary<string, List<compiler_directive>> GetCompilerDirectives(List<
else if (cd.name.Equals("mainresource", StringComparison.CurrentCultureIgnoreCase))
throw new DuplicateDirective(cd.location.doc.file_name, "mainresource", cd.location);
directives[cd.name].Insert(0, cd);
if (!knownDirectives.Contains(cd.name.ToLower()))
warnings.Add(new Errors.CommonWarning(string.Format(StringResources.Get("WARNING_UNKNOWN_DIRECTIVE"), cd.name), cd.location.doc.file_name, cd.location.begin_line_num, cd.location.begin_column_num));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Compiler/PCU/PCUFileFormatVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace PascalABCCompiler.PCU
{
public static class PCUFileFormatVersion
{
public static System.Int16 Version = 118;
public static System.Int16 Version = 119;
}
}
12 changes: 10 additions & 2 deletions Compiler/PCU/PCUReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,13 @@ public CompilationUnit GetCompilationUnit(string FileName, bool readDebugInfo)
AddTypeSynonyms(pcu_file.interface_synonyms_offset, cun.scope);
AddTypeSynonyms(pcu_file.implementation_synonyms_offset, cun.implementation_scope);
//\ssyy

for (int i = 0; i < pcu_file.names.Length; i++)
{
if (pcu_file.names[i].always_restore)
{
cun.scope.Find(pcu_file.names[i].name);
}
}

ChangeState(this, PCUReaderWriterState.EndReadTree, unit);
return unit;
Expand Down Expand Up @@ -578,6 +584,7 @@ private void ReadPCUHeader()
pcu_file.names[i].offset = br.ReadInt32();
pcu_file.names[i].symbol_kind = (symbol_kind)br.ReadByte();
pcu_file.names[i].special_scope = br.ReadByte();
pcu_file.names[i].always_restore = br.ReadBoolean();
}
//ssyy
num_names = br.ReadInt32();
Expand All @@ -588,6 +595,7 @@ private void ReadPCUHeader()
pcu_file.implementation_names[i].offset = br.ReadInt32();
pcu_file.implementation_names[i].symbol_kind = (symbol_kind)br.ReadByte();
pcu_file.implementation_names[i].special_scope = br.ReadByte();
pcu_file.implementation_names[i].always_restore = br.ReadBoolean();
}
//\ssyy
int num_incl = br.ReadInt32();
Expand Down Expand Up @@ -2567,7 +2575,7 @@ private string[] AddClassMemberNames(WrappedClassScope scope)

si.symbol_kind = (symbol_kind)br.ReadByte();
si.semantic_node_type = (semantic_node_type)br.ReadByte();
si.virtual_slot = br.ReadBoolean();
si.always_restore = br.ReadBoolean();
si.is_static = br.ReadBoolean();
//Вроде это ненужно
//SymbolInfo si2 = scope.FindWithoutCreation(name);
Expand Down
4 changes: 3 additions & 1 deletion Compiler/PCU/PCUWrappers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ private bool needRestore(PCUSymbolInfo pcu_tsi, string name)
{
if (pcu_tsi == null)
return true;
if (pcu_tsi.semantic_node_type == semantic_node_type.common_method_node && pcu_tsi.virtual_slot)
//if (pcu_tsi.semantic_node_type == semantic_node_type.common_method_node && pcu_tsi.virtual_slot)
// return true;
if (pcu_tsi.always_restore)
return true;
if (hasNotRestoreAttribute())
return false;
Expand Down
31 changes: 28 additions & 3 deletions Compiler/PCU/PCUWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class NameRef {
public byte special_scope=0;//говорит о том что этот символ добавляется не в пространсво имен модуля
public int index;//не сериализуется
public semantic_node_type semantic_node_type;
public bool virtual_slot;
public bool always_restore;
public bool is_static;

public NameRef(string name, int index, TreeConverter.access_level access_level, semantic_node_type semantic_node_type)
Expand Down Expand Up @@ -441,6 +441,7 @@ private void WritePCUHeader(BinaryWriter fbw)
fbw.Write(pcu_file.names[i].offset);
fbw.Write((byte)pcu_file.names[i].symbol_kind);
fbw.Write(pcu_file.names[i].special_scope);
fbw.Write(pcu_file.names[i].always_restore);
}

//ssyy
Expand All @@ -451,6 +452,7 @@ private void WritePCUHeader(BinaryWriter fbw)
fbw.Write(pcu_file.implementation_names[i].offset);
fbw.Write((byte)pcu_file.implementation_names[i].symbol_kind);
fbw.Write(pcu_file.implementation_names[i].special_scope);
fbw.Write(pcu_file.implementation_names[i].always_restore);
}
//\ssyy

Expand Down Expand Up @@ -812,6 +814,17 @@ private string GetSynonimName(common_namespace_node cnn, compiled_type_node ctn)
return ctn.name;
}
//ssyy

private bool HasPCUAlwaysRestoreAttribute(definition_node dn)
{
foreach (var attr in dn.attributes)
{
if (attr.attribute_type.full_name == "PABCSystem.PCUAlwaysRestoreAttribute")
return true;
}
return false;
}

private void FillNames(NameRef[] name_array, Dictionary<definition_node, NameRef> pools)
{
int j = 0, i = 0;
Expand All @@ -838,12 +851,16 @@ private void FillNames(NameRef[] name_array, Dictionary<definition_node, NameRef
else
name_array[i].symbol_kind = symbol_kind.sk_overload_procedure;
}
if (HasPCUAlwaysRestoreAttribute(cur_cnn.functions[i - j]))
name_array[i].always_restore = true;
pools[cur_cnn.functions[i - j]] = name_array[i];
}
j = i;
for (i = j; i < cur_cnn.non_template_types.Count + j; i++)
{
name_array[i] = new NameRef(cur_cnn.non_template_types[i - j].name, i);
if (HasPCUAlwaysRestoreAttribute(cur_cnn.non_template_types[i - j]))
name_array[i].always_restore = true;
pools[cur_cnn.non_template_types[i - j]] = name_array[i];
}
j = i;
Expand All @@ -864,6 +881,8 @@ private void FillNames(NameRef[] name_array, Dictionary<definition_node, NameRef
for (i = j; i < cur_cnn.variables.Count + j; i++)
{
name_array[i] = new NameRef(cur_cnn.variables[i - j].name, i);
if (HasPCUAlwaysRestoreAttribute(cur_cnn.variables[i - j]))
name_array[i].always_restore = true;
pools[cur_cnn.variables[i - j]] = name_array[i];
}
j = i;
Expand Down Expand Up @@ -2707,6 +2726,8 @@ private void VisitTypeDefinition(common_type_node type)
names[i] = new NameRef(type.fields[i - j].name, i, convert_field_access_level(type.fields[i - j].field_access_level), type.fields[i - j].semantic_node_type);
name_pool[type.fields[i - j]] = names[i];
names[i].is_static = type.fields[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static;
if (HasPCUAlwaysRestoreAttribute(type.fields[i - j]))
names[i].always_restore = true;
size += names[i].Size;
}
j = i;
Expand All @@ -2715,6 +2736,8 @@ private void VisitTypeDefinition(common_type_node type)
names[i] = new NameRef(type.properties[i - j].name, i, convert_field_access_level(type.properties[i - j].field_access_level), type.properties[i - j].semantic_node_type);
name_pool[type.properties[i - j]] = names[i];
names[i].is_static = type.properties[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static;
if (HasPCUAlwaysRestoreAttribute(type.properties[i - j]))
names[i].always_restore = true;
size += names[i].Size;
}
j = i;
Expand All @@ -2724,8 +2747,10 @@ private void VisitTypeDefinition(common_type_node type)
name_pool[type.methods[i - j]] = names[i];
if (type.methods[i - j].is_overload)
names[i].symbol_kind = symbol_kind.sk_overload_function;
names[i].virtual_slot = type.methods[i - j].newslot_awaited || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract || type.methods[i - j].is_constructor;
names[i].always_restore = type.methods[i - j].newslot_awaited || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual || type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract || type.methods[i - j].is_constructor;
names[i].is_static = type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static && !type.methods[i - j].is_constructor;
if (!names[i].always_restore && HasPCUAlwaysRestoreAttribute(type.methods[i - j]))
names[i].always_restore = true;
size += names[i].Size;
}
j = i;
Expand Down Expand Up @@ -2907,7 +2932,7 @@ private void VisitTypeMemberDefinition(common_type_node ctn)
bw.Write((byte)names[i].access_level);
bw.Write((byte)names[i].symbol_kind);
bw.Write((byte)names[i].semantic_node_type);
bw.Write(names[i].virtual_slot);
bw.Write(names[i].always_restore);
bw.Write(names[i].is_static);
}
bw.BaseStream.Seek(tmp, SeekOrigin.Begin);
Expand Down
2 changes: 1 addition & 1 deletion Configuration/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "9";
public const string Build = "0";
public const string Revision = "3408";
public const string Revision = "3411";

public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Expand Down
4 changes: 2 additions & 2 deletions Configuration/Version.defs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=3408
%MINOR%=9
%REVISION%=3411
%COREVERSION%=0
%MAJOR%=3
2 changes: 1 addition & 1 deletion LambdaAnySynToSemConverter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LambdaAnyTypeNodeSyntaxToSemanticConverter")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Binary file modified Localization/DefaultLang.resources
Binary file not shown.
2 changes: 1 addition & 1 deletion Localization/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Localization")]
[assembly: AssemblyCopyright("Copyright © 2005-2023 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyCopyright("Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
15 changes: 15 additions & 0 deletions NETGenerator/NETGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ private void MakeAttribute(ICommonFunctionNode func)
{
MethodBuilder mb = helper.GetMethod(func).mi as MethodBuilder;
IAttributeNode[] attrs = func.Attributes;
List<CustomAttributeBuilder> returnValueAttrs = new List<CustomAttributeBuilder>();
for (int i = 0; i < attrs.Length; i++)
{

Expand All @@ -2216,6 +2217,7 @@ private void MakeAttribute(ICommonFunctionNode func)
{
var constr = (attrs[i].AttributeConstructor is ICompiledConstructorNode) ? (attrs[i].AttributeConstructor as ICompiledConstructorNode).constructor_info : helper.GetConstructor(attrs[i].AttributeConstructor).cnstr;

if (attrs[i].Arguments.Length > 0 && helper.GetTypeReference(attrs[i].AttributeType).tp.FullName == "System.Runtime.InteropServices.MarshalAsAttribute")
try
{
mb.SetMarshal(UnmanagedMarshal.DefineUnmanagedMarshal((UnmanagedType)attrs[i].Arguments[0].value));
Expand All @@ -2224,10 +2226,20 @@ private void MakeAttribute(ICommonFunctionNode func)
{
throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace(", переданный для DefineUnmanagedMarshal,",""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num);
}
else
{
returnValueAttrs.Add(cab);
}
}
else
mb.SetCustomAttribute(cab);
}
if (returnValueAttrs.Count > 0)
{
ParameterBuilder pb = mb.DefineParameter(0, ParameterAttributes.Retval, null);
foreach (var attr in returnValueAttrs)
pb.SetCustomAttribute(attr);
}
foreach (IParameterNode pn in func.parameters)
{
ParamInfo pi = helper.GetParameter(pn);
Expand Down Expand Up @@ -11599,7 +11611,10 @@ public override void visit(IForeachNode value)
}
LocalBuilder lb = il.DeclareLocal(return_type);
if (save_debug_info) lb.SetLocalSymInfo("$enumer$" + uid++);

value.InWhatExpr.visit(this);
if (value.InWhatExpr.type.is_value_type)
il.Emit(OpCodes.Box, in_what_type);
il.Emit(OpCodes.Callvirt, enumer_mi);
il.Emit(OpCodes.Stloc, lb);
Label exl = il.BeginExceptionBlock();
Expand Down
2 changes: 1 addition & 1 deletion Optimizer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Optimizer")]
[assembly: AssemblyCopyright("Copyright © 2005-2023 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyCopyright("Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 1 addition & 1 deletion Optimizer/SemanticTreeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public string Version

public string Copyright
{
get { return "Copyright © 2005-2023 by Ivan Bondarev, Stanislav Mikhalkovich"; }
get { return "Copyright © 2005-2024 by Ivan Bondarev, Stanislav Mikhalkovich"; }
}

public PascalABCCompiler.SemanticTreeConverters.ConverterType ConverterType
Expand Down
2 changes: 1 addition & 1 deletion Parsers/PascalABCParserNewSaushkin/ABCPascal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-G8V08V4
// DateTime: 31.12.2023 18:49:08
// DateTime: 03.01.2024 10:26:46
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
Expand Down
4 changes: 2 additions & 2 deletions Parsers/PascalABCParserNewSaushkin/ABCPascal.y
Original file line number Diff line number Diff line change
Expand Up @@ -4213,8 +4213,6 @@ factor
{ $$ = $1; }
| tuple
{ $$ = $1; }
| tkRoundOpen tkVar identifier tkAssign expr_dq tkRoundClose
{ $$ = new let_var_expr($3,$5,@$); }
;

literal_or_number
Expand Down Expand Up @@ -4249,6 +4247,8 @@ var_reference
{ $$ = $1; }
| var_question_point
{ $$ = $1; }
| tkRoundOpen tkVar identifier tkAssign expr_dq tkRoundClose
{ $$ = new let_var_expr($3,$5,@$); }
;

var_address
Expand Down
Loading

0 comments on commit 29dc93f

Please sign in to comment.