Merge remote-tracking branch 'remotes/upstream/master'

# Conflicts:
#	Configuration/GlobalAssemblyInfo.cs
#	Configuration/Version.defs
#	ReleaseGenerators/PascalABCNET_version.nsh
#	TreeConverter/TreeConversion/compilation_context.cs
#	TreeConverter/TreeConversion/syntax_tree_visitor.cs
#	bin/Lib/PABCRtl.dll
This commit is contained in:
andrewlord607 2017-05-30 20:25:14 +03:00
commit 31af590e95
116 changed files with 9820 additions and 2939 deletions

View file

@ -1711,23 +1711,23 @@ namespace PascalABCCompiler
}
private ProjectInfo project;
private void PrepareCompileOptionsForProject()
{
project = new ProjectInfo();
project.Load(CompilerOptions.SourceFileName);
//LoadProject(CompilerOptions.SourceFileName);
switch (project.ProjectType)
{
case ProjectType.ConsoleApp : CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; break;
case ProjectType.WindowsApp : CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; break;
case ProjectType.Library : CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; break;
}
CompilerOptions.SourceFileName = project.main_file;
CompilerOptions.Debug = project.include_debug_info;
CompilerOptions.OutputFileName = project.output_file_name;
CompilerOptions.OutputDirectory = project.output_directory;
project = new ProjectInfo();
project.Load(CompilerOptions.SourceFileName);
//LoadProject(CompilerOptions.SourceFileName);
switch (project.ProjectType)
{
case ProjectType.ConsoleApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; break;
case ProjectType.WindowsApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; break;
case ProjectType.Library: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; break;
}
CompilerOptions.SourceFileName = project.main_file;
CompilerOptions.Debug = project.include_debug_info;
CompilerOptions.OutputFileName = project.output_file_name;
CompilerOptions.OutputDirectory = project.output_directory;
}
public string Compile()

View file

@ -6,6 +6,6 @@ namespace PascalABCCompiler.PCU
{
public static class PCUFileFormatVersion
{
public static System.Int16 Version = 105;
public static System.Int16 Version = 106;
}
}

View file

@ -3142,7 +3142,10 @@ namespace PascalABCCompiler.PCU
filter_type = GetTypeReference();
local_block_variable_reference exception_var = null;
if (CanReadObject())
{
CreateLocalBlockVariable(null);
exception_var = (local_block_variable_reference)CreateLocalBlockVariableReference();
}
efl.AddElement(new exception_filter(filter_type,exception_var,CreateStatement(),ReadDebugInfo()));
}
return new try_block(try_statements, finally_statements, efl, null);

View file

@ -3190,7 +3190,10 @@ namespace PascalABCCompiler.PCU
if (CanWriteObject(ef.filter_type))
WriteTypeReference(ef.filter_type);
if (CanWriteObject(ef.exception_var))
{
VisitLocalBlockVariable(ef.exception_var.var);
VisitLocalBlockVariableReference(ef.exception_var);
}
VisitStatement(ef.exception_handler);
WriteDebugInfo(ef.location);
}

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "2";
public const string Build = "0";
public const string Revision = "1439";
public const string Revision = "1463";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=1439
%REVISION%=1463
%MINOR%=2
%MAJOR%=3

View file

@ -5616,9 +5616,14 @@ namespace PascalABCCompiler.NETGenerator
else
typ = TypeFactory.ExceptionType;
il.BeginCatchBlock(typ);
if (iefbn.ExceptionInstance != null)
{
il.Emit(OpCodes.Stloc, helper.GetVariable(iefbn.ExceptionInstance.Variable).lb);
LocalBuilder lb = il.DeclareLocal(typ);
helper.AddVariable(iefbn.ExceptionInstance.Variable, lb);
if (save_debug_info && iefbn.ExceptionInstance.Location != null)
lb.SetLocalSymInfo(iefbn.ExceptionInstance.Variable.name + ":" + iefbn.ExceptionInstance.Location.begin_line_num + ":" + iefbn.ExceptionInstance.Location.end_line_num);
il.Emit(OpCodes.Stloc, lb);
}
else
{
@ -6593,8 +6598,19 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Stloc, start_index_lb);
il.MarkLabel(lbl);
}
//len_lb = EmitArguments(parameters, real_parameters, mi);
for (int i = 0; i < real_parameters.Length; i++)
{
if (real_parameters[i] is INullConstantNode && parameters[i].type.is_nullable_type)
{
Type tp = helper.GetTypeReference(parameters[i].type).tp;
LocalBuilder lb = il.DeclareLocal(tp);
il.Emit(OpCodes.Ldloca, lb);
il.Emit(OpCodes.Initobj, tp);
il.Emit(OpCodes.Ldloc, lb);
continue;
}
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
//TODO:Переделать.
@ -6690,7 +6706,8 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Ldloca, lb);
}
is_dot_expr = false;
for (int i = 0; i < real_parameters.Length; i++)
EmitArguments(parameters, real_parameters);
/*for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
@ -6702,7 +6719,7 @@ namespace PascalABCCompiler.NETGenerator
if (ctn2 != null && (ctn3.is_value_type || ctn3.is_generic_parameter) && ctn2.compiled_type == TypeFactory.ObjectType)
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
is_addr = false;
}
}*/
MethodInfo mi = value.compiled_method.method_info;
if (value.compiled_method.comperehensive_type.is_value_type || !value.virtual_call && value.compiled_method.polymorphic_state == polymorphic_state.ps_virtual || value.compiled_method.polymorphic_state == polymorphic_state.ps_static)
{
@ -6746,7 +6763,8 @@ namespace PascalABCCompiler.NETGenerator
is_dot_expr = false;
bool is_comp_gen = false;
IParameterNode[] parameters = value.static_method.parameters;
for (int i = 0; i < real_parameters.Length; i++)
EmitArguments(parameters, real_parameters);
/*for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
@ -6774,7 +6792,7 @@ namespace PascalABCCompiler.NETGenerator
if (box_awaited)
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
is_addr = false;
}
}*/
//if (save_debug_info && need_fee)
// MarkSequencePoint(il, value.Location);
il.EmitCall(OpCodes.Call, mi, null);
@ -6846,7 +6864,8 @@ namespace PascalABCCompiler.NETGenerator
//bool is_comp_gen = false;
//bool need_fee = false;
IParameterNode[] parameters = value.method.parameters;
for (int i = 0; i < real_parameters.Length; i++)
EmitArguments(parameters, real_parameters);
/*for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
@ -6876,7 +6895,7 @@ namespace PascalABCCompiler.NETGenerator
if (box_awaited)
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
is_addr = false;
}
}*/
//вызов метода
//(ssyy) Функции размерных типов всегда вызываются через call
if (value.method.comperehensive_type.is_value_type || !value.virtual_call && value.method.polymorphic_state == polymorphic_state.ps_virtual || value.method.polymorphic_state == polymorphic_state.ps_static /*|| !value.virtual_call || (value.method.polymorphic_state != polymorphic_state.ps_virtual && value.method.polymorphic_state != polymorphic_state.ps_virtual_abstract && !value.method.common_comprehensive_type.IsInterface)*/)
@ -7236,41 +7255,10 @@ namespace PascalABCCompiler.NETGenerator
}
bool tmp_dot = is_dot_expr;
is_dot_expr = false;
bool is_comp_gen = false;
MethodInfo mi = meth.mi;
IParameterNode[] parameters = value.namespace_function.parameters;
for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
ITypeNode ctn = real_parameters[i].type;
TypeInfo ti = null;
//(ssyy) moved up
ITypeNode tn2 = parameters[i].type;
ICompiledTypeNode ctn2 = tn2 as ICompiledTypeNode;
ITypeNode ctn3 = real_parameters[i].type;
//(ssyy) 07.12.2007 При боксировке нужно вызывать Ldsfld вместо Ldsflda.
//Дополнительная проверка введена именно для этого.
bool box_awaited =
(ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode) && (ctn3.is_value_type || ctn3.is_generic_parameter);
if (!(real_parameters[i] is INullConstantNode))
{
ti = helper.GetTypeReference(ctn);
if (ti.clone_meth != null && ti.tp != null && ti.tp.IsValueType && !box_awaited && !parameters[i].is_const)
is_dot_expr = true;
}
//if (is_comp_gen == false)
is_comp_gen = CheckForCompilerGenerated(real_parameters[i]);
real_parameters[i].visit(this);
is_dot_expr = false;
CallCloneIfNeed(il, parameters[i], real_parameters[i]);
if (box_awaited)
{
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
}
is_addr = false;
}
EmitArguments(parameters, real_parameters);
il.EmitCall(OpCodes.Call, mi, null);
EmitFreePinnedVariables();
if (tmp_dot == true)
@ -7290,7 +7278,52 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Nop);
//if (is_stmt == true) il.Emit(OpCodes.Pop);
}
private void EmitArguments(IParameterNode[] parameters, IExpressionNode[] real_parameters)
{
bool is_comp_gen = false;
for (int i = 0; i < real_parameters.Length; i++)
{
if (real_parameters[i] is INullConstantNode && parameters[i].type.is_nullable_type)
{
Type tp = helper.GetTypeReference(parameters[i].type).tp;
LocalBuilder lb = il.DeclareLocal(tp);
il.Emit(OpCodes.Ldloca, lb);
il.Emit(OpCodes.Initobj, tp);
il.Emit(OpCodes.Ldloc, lb);
continue;
}
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
ITypeNode ctn = real_parameters[i].type;
TypeInfo ti = null;
//(ssyy) moved up
ITypeNode tn2 = parameters[i].type;
ICompiledTypeNode ctn2 = tn2 as ICompiledTypeNode;
ITypeNode ctn3 = real_parameters[i].type;
//(ssyy) 07.12.2007 При боксировке нужно вызывать Ldsfld вместо Ldsflda.
//Дополнительная проверка введена именно для этого.
bool box_awaited =
(ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode) && (ctn3.is_value_type || ctn3.is_generic_parameter);
if (!(real_parameters[i] is INullConstantNode))
{
ti = helper.GetTypeReference(ctn);
if (ti.clone_meth != null && ti.tp != null && ti.tp.IsValueType && !box_awaited && !parameters[i].is_const)
is_dot_expr = true;
}
is_comp_gen = CheckForCompilerGenerated(real_parameters[i]);
real_parameters[i].visit(this);
is_dot_expr = false;
CallCloneIfNeed(il, parameters[i], real_parameters[i]);
if (box_awaited)
{
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
}
is_addr = false;
}
}
private void EmitFreePinnedVariables()
{
/*foreach (LocalBuilder lb in pinned_variables)
@ -7312,7 +7345,7 @@ namespace PascalABCCompiler.NETGenerator
if (to.type.is_value_type)
{
//ti = helper.GetTypeReference(to.type);
if (ti.assign_meth != null)
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldsflda, fb);
}
else if (to.type.type_special_kind == type_special_kind.set_type && !in_var_init)
@ -7323,6 +7356,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7330,7 +7368,7 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
//это если например переменной типа object присваивается число
EmitBox(from, fb.FieldType);
@ -7404,8 +7442,9 @@ namespace PascalABCCompiler.NETGenerator
if (to.type.is_value_type)
{
//ti = helper.GetTypeReference(to.type);
if (ti.assign_meth != null)
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldloca, lb);
}
else if (to.type.type_special_kind == type_special_kind.set_type && !in_var_init)
{
@ -7415,6 +7454,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7441,7 +7485,8 @@ namespace PascalABCCompiler.NETGenerator
if (to.type.is_value_type)
{
//ti = helper.GetTypeReference(to.type);
if (ti.assign_meth != null) il.Emit(OpCodes.Ldflda, fb);
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldflda, fb);
}
else if (to.type.type_special_kind == type_special_kind.set_type && !in_var_init)
{
@ -7451,6 +7496,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7458,6 +7508,7 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
EmitBox(from, fb.FieldType);
CheckArrayAssign(to, from, il);
il.Emit(OpCodes.Stfld, fb);
@ -7501,7 +7552,8 @@ namespace PascalABCCompiler.NETGenerator
TypeInfo ti = helper.GetTypeReference(to.type);
if (to.type.is_value_type)
{
if (ti.assign_meth != null) il.Emit(OpCodes.Ldarga, pos);
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldarga, pos);
}
else if (to.type.type_special_kind == type_special_kind.set_type)
{
@ -7511,6 +7563,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7518,10 +7575,13 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
BoxAssignToParameter(to, from);
//il.Emit(OpCodes.Dup);
if (pos <= 255) il.Emit(OpCodes.Starg_S, pos);
else il.Emit(OpCodes.Starg, pos);
if (pos <= 255)
il.Emit(OpCodes.Starg_S, pos);
else
il.Emit(OpCodes.Starg, pos);
}
else
{
@ -7537,6 +7597,12 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Ldarg, pos);
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
}
else if (to.type.type_special_kind == type_special_kind.set_type)
{
@ -7573,7 +7639,8 @@ namespace PascalABCCompiler.NETGenerator
if (to.type.is_value_type)
{
//ti = helper.GetTypeReference(to.type);
if (ti.assign_meth != null) il.Emit(OpCodes.Ldflda, fb);
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldflda, fb);
}
else if (to.type.type_special_kind == type_special_kind.set_type)
{
@ -7583,6 +7650,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7590,6 +7662,7 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
BoxAssignToParameter(to, from);
//il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Stfld, fb);
@ -7607,6 +7680,11 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
}
else if (to.type.type_special_kind == type_special_kind.set_type)
{
@ -7643,7 +7721,7 @@ namespace PascalABCCompiler.NETGenerator
TypeInfo ti = helper.GetTypeReference(to.type);
if (to.type.is_value_type)
{
if (ti.assign_meth != null)
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldflda, fi);
}
else if (to.type.type_special_kind == type_special_kind.set_type && !in_var_init)
@ -7654,6 +7732,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7672,6 +7755,7 @@ namespace PascalABCCompiler.NETGenerator
}
return;
}
EmitBox(from, fi_info.field_type);
CheckArrayAssign(to, from, il);
il.Emit(OpCodes.Stfld, fi);
@ -7694,7 +7778,8 @@ namespace PascalABCCompiler.NETGenerator
if (to.type.is_value_type)
{
//ti = helper.GetTypeReference(to.type);
if (ti.assign_meth != null) il.Emit(OpCodes.Ldsflda, fi);
if (ti.assign_meth != null || from is INullConstantNode && to.type.is_nullable_type)
il.Emit(OpCodes.Ldsflda, fi);
}
else if (to.type.type_special_kind == type_special_kind.set_type)
{
@ -7704,6 +7789,11 @@ namespace PascalABCCompiler.NETGenerator
return;
}
else ti = null;
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, ti.tp);
return;
}
//что присвоить
from.visit(this);
if (ti != null && ti.assign_meth != null)
@ -7711,6 +7801,7 @@ namespace PascalABCCompiler.NETGenerator
il.Emit(OpCodes.Call, ti.assign_meth);
return;
}
EmitBox(from, fi.FieldType);
CheckArrayAssign(to, from, il);
il.Emit(OpCodes.Stsfld, fi);
@ -7789,12 +7880,10 @@ namespace PascalABCCompiler.NETGenerator
for (int i = 0; i < value.indices.Length; i++)
value.indices[i].visit(this);
}
if (elem_type.IsValueType == true && TypeFactory.IsStandType(elem_type) == false && !TypeIsEnum(elem_type))
if (elem_type.IsValueType && !TypeFactory.IsStandType(elem_type) && !TypeIsEnum(elem_type) || to.type.is_nullable_type)
{
if (value.indices == null)
il.Emit(OpCodes.Ldelema, elem_type);
//else
// il.Emit(OpCodes.Call, addr_meth);
}
else if (elem_ti != null && elem_ti.assign_meth != null)
{
@ -7803,6 +7892,11 @@ namespace PascalABCCompiler.NETGenerator
else
il.Emit(OpCodes.Call, get_meth);
}
if (from is INullConstantNode && to.type.is_nullable_type)
{
il.Emit(OpCodes.Initobj, elem_type);
return;
}
from.visit(this);
if (elem_ti != null && elem_ti.assign_meth != null)
{
@ -8253,6 +8347,43 @@ namespace PascalABCCompiler.NETGenerator
case basic_function_type.booldec:
case basic_function_type.cdec: ConvertDec(real_parameters[0]); return;
}
if (real_parameters.Length > 1)
{
if (real_parameters[0].type.is_nullable_type && real_parameters[1] is INullConstantNode)
{
bool tmp = is_dot_expr;
is_dot_expr = true;
TypeInfo ti = helper.GetTypeReference(real_parameters[0].type);
real_parameters[0].visit(this);
is_dot_expr = tmp;
MethodInfo mi = null;
if (real_parameters[0].type is IGenericTypeInstance)
mi = TypeBuilder.GetMethod(ti.tp, typeof(Nullable<>).GetMethod("get_HasValue"));
else
mi = ti.tp.GetMethod("get_HasValue");
il.Emit(OpCodes.Call, mi);
if (ft == basic_function_type.objeq)
il.Emit(OpCodes.Not);
return;
}
else if (real_parameters[1].type.is_nullable_type && real_parameters[0] is INullConstantNode)
{
bool tmp = is_dot_expr;
is_dot_expr = true;
TypeInfo ti = helper.GetTypeReference(real_parameters[1].type);
real_parameters[1].visit(this);
is_dot_expr = tmp;
MethodInfo mi = null;
if (real_parameters[1].type is IGenericTypeInstance)
mi = TypeBuilder.GetMethod(ti.tp, typeof(Nullable<>).GetMethod("get_HasValue"));
else
mi = ti.tp.GetMethod("get_HasValue");
il.Emit(OpCodes.Call, mi);
if (ft == basic_function_type.objeq)
il.Emit(OpCodes.Not);
return;
}
}
real_parameters[0].visit(this);
if (real_parameters.Length > 1)
real_parameters[1].visit(this);
@ -9133,8 +9264,8 @@ namespace PascalABCCompiler.NETGenerator
is_dot_expr = false;
bool need_fee = false;
bool is_comp_gen = false;
for (int i = 0; i < real_parameters.Length; i++)
EmitArguments(parameters, real_parameters);
/*for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
@ -9170,7 +9301,7 @@ namespace PascalABCCompiler.NETGenerator
if (box_awaited)
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
is_addr = false;
}
}*/
/*if (save_debug_info && need_fee)
{
MarkSequencePoint(il, value.Location);
@ -9250,7 +9381,8 @@ namespace PascalABCCompiler.NETGenerator
//\ssyy
is_dot_expr = false;
for (int i = 0; i < real_parameters.Length; i++)
EmitArguments(parameters, real_parameters);
/*for (int i = 0; i < real_parameters.Length; i++)
{
if (parameters[i].parameter_type == parameter_type.var)
is_addr = true;
@ -9260,7 +9392,7 @@ namespace PascalABCCompiler.NETGenerator
if (ctn2 != null && !(real_parameters[i] is SemanticTree.INullConstantNode) && value.type != null && (ctn3.is_value_type || ctn3.is_generic_parameter) && ctn2.compiled_type == TypeFactory.ObjectType)
il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp);
is_addr = false;
}
}*/
//ssyy изменил
if (value.new_obj_awaited())
{

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-8EAQPI9
// DateTime: 06.05.2017 15:45:18
// DateTime: 22.05.2017 12:38:20
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
// SSM 21/11/16 Ëÿìáäà âûðàæåíèÿ âûíåñåíû íà âåðõíèé óðîâåíü (ï.÷. ïðèñâàèâàíèÿ è ïàðàìåòðû)
%{
// Ýòè îáúÿâëåíèÿ äîáàâëÿþòñÿ â êëàññ GPPGParser, ïðåäñòàâëÿþùèé ñîáîé ïàðñåð, ãåíåðèðóåìûé ñèñòåìîé gppg
@ -3108,6 +3110,10 @@ variable
{
$$ = new dot_node($1 as addressed_value, $3 as addressed_value, @$);
}
| tuple tkPoint identifier_keyword_operatorname
{
$$ = new dot_node($1 as addressed_value, $3 as addressed_value, @$);
}
/*| variable tkQuestionPoint identifier_keyword_operatorname
{
$$ = new dot_question_node($1 as addressed_value, $3 as addressed_value, @$);

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View file

@ -165,5 +165,6 @@ script=

View file

@ -1,9 +1,9 @@
//
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: SSM
// DateTime: 10.01.2013 23:30:56
// UserName: ?????????
// Machine: IVAN-PC
// DateTime: 09.05.2017 19:33:10
// UserName: Ivan
// GPLEX input file <Preprocessor3.lex>
// GPLEX frame file <embedded resource>
//
@ -634,10 +634,7 @@ return (int)Tokens.NODIRECTIVE;
BEGIN(INSIDEDIRECTIVE);
break;
case 3:
if (yytext.Contains("\n"))
Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,"error: LF into directive");
//else Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,yytext);
yylval = new Directive(yytext, new LexLocation(tokLin, tokCol, tokELin, tokECol));
yylval = new Directive(yytext, new LexLocation(tokLin, tokCol, tokELin, tokECol));
var t1 = yylloc;
return (int)Tokens.DIRECTIVE;
break;

View file

@ -23,8 +23,8 @@ NODIRECTIVE [.|\n]+
}
<INSIDEDIRECTIVE> {DIRECTIVE} {
if (yytext.Contains("\n"))
Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,"error: LF into directive");
//if (yytext.Contains("\n"))
// Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,"error: LF into directive");
//else Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,yytext);
yylval = new Directive(yytext, new LexLocation(tokLin, tokCol, tokELin, tokECol));
var t1 = yylloc;

View file

@ -3,9 +3,9 @@
// (see accompanying GPPGcopyright.rtf)
// GPPG version 1.3.6
// Machine: SSM
// DateTime: 10.01.2013 23:30:56
// UserName: ?????????
// Machine: IVAN-PC
// DateTime: 09.05.2017 19:33:14
// UserName: Ivan
// Input file <Preprocessor3Yacc.y>
// options: no-lines gplex

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualPascalABCNET", "VisualPascalABCNET", "{26843C5D-9D7E-4C2C-AC14-2D227FA5592E}"
EndProject
@ -99,8 +99,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldHelpers", "Yield\Yield
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxVisitors", "SyntaxVisitors\SyntaxVisitors.csproj", "{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldConversionSyntax", "Yield\YieldConversionSyntax\YieldConversionSyntax.csproj", "{276EE073-60F6-46D2-8811-1B8026BCAADA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -443,16 +441,6 @@ Global
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|x86.ActiveCfg = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|x86.ActiveCfg = Debug|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.Build.0 = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -494,6 +482,5 @@ Global
{F10A5330-DCF4-4533-877C-7B1B1BE23884} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2} = {F8CE2712-826B-450B-A72F-D32D80C99858}
{276EE073-60F6-46D2-8811-1B8026BCAADA} = {F8CE2712-826B-450B-A72F-D32D80C99858}
EndGlobalSection
EndGlobal

View file

@ -372,6 +372,7 @@ namespace VisualPascalABCPlugins
void ExecUndo();
void ExecRedo();
void CollapseRegions();
void CodeFormat();
}
public interface IWorkbenchDebuggerOperationsService
@ -428,6 +429,14 @@ namespace VisualPascalABCPlugins
IWorkbenchDesignerService DesignerService { get; }
IWorkbenchOperationsService OperationsService { get; }
IWorkbenchUpdateService UpdateService { get; }
ICodeCompletionService CodeCompletionService { get; }
}
public interface ICodeCompletionService
{
PascalABCCompiler.Parsers.ICodeCompletionDomConverter GetConverter(string FileName);
void SetAsChanged(string FileName);
void RegisterFileForParsing(string FileName);
}
public interface IWorkbench
@ -443,7 +452,6 @@ namespace VisualPascalABCPlugins
ICompilerConsoleWindow CompilerConsoleWindow { get; }
IOutputWindow OutputWindow { get; }
IErrorListWindow ErrorsListWindow { get; }
void BeginInvoke(Delegate del, params object[] args);
}
@ -477,7 +485,17 @@ namespace VisualPascalABCPlugins
IValue ObjectValue { get; }
object PrimitiveValue { get; }
}
public interface IProcess
{
bool HasExited { get; }
}
public interface IProcessEventArgs
{
IProcess Process { get; }
}
public interface IDebuggerManager
{
bool IsRunning { get; }
@ -491,6 +509,7 @@ namespace VisualPascalABCPlugins
void StepInto();
void StepOver();
void RunToCursor();
event EventHandler<EventArgs> DebuggeeStateChanged;
}
public interface ILanguageManager

View file

@ -2,4 +2,5 @@
"..\utils\NSIS\Unicode\makensis.exe" PascalABCNETStandart.nsi
"..\utils\NSIS\Unicode\makensis.exe" PascalABCNETWithDotNet.nsi
PascalABCNETConsoleZIP.bat
PascalABCNETMonoZIP.bat
PascalABCNETMonoZIP.bat
PAUSE

View file

@ -1 +1 @@
!define VERSION '3.2.0.1439'
!define VERSION '3.2.0.1463'

View file

@ -12,7 +12,6 @@
File "..\bin\SyntaxTree.dll"
File "..\bin\SyntaxTreeConverters.dll"
File "..\bin\SyntaxVisitors.dll"
File "..\bin\YieldConversionSyntax.dll"
File "..\bin\YieldHelpers.dll"
File "..\bin\ICSharpCode.NRefactory.dll"
File "..\bin\TreeConverter.dll"
@ -50,7 +49,6 @@
${AddFile} "SyntaxTreeConverters.dll"
${AddFile} "YieldHelpers.dll"
${AddFile} "SyntaxVisitors.dll"
${AddFile} "YieldConversionSyntax.dll"
${AddFile} "ICSharpCode.NRefactory.dll"
${AddFile} "TreeConverter.dll"
${AddFile} "OptimizerConversion.dll"
@ -106,6 +104,7 @@
File ..\bin\Lib\ClientServer.pcu
File ..\bin\Lib\OpenGL.pcu
File ..\bin\Lib\PT4MakerNetX.pcu
File ..\bin\Lib\Speech.pcu
File ..\bin\Lib\PABCRtl.dll
File ..\bin\Lib\PABCRtl32.dll
@ -153,6 +152,7 @@
${AddFile} "ClientServer.pcu"
${AddFile} "OpenGL.pcu"
${AddFile} "PT4MakerNetX.pcu"
${AddFile} "Speech.pcu"
${AddFile} "PABCRtl.dll"
${AddFile} "PABCRtl.pdb"
Push "Lib\PABCRtl.dll"
@ -201,6 +201,7 @@
File ..\bin\Lib\ClientServer.pas
File ..\bin\Lib\OpenGL.pas
File ..\bin\Lib\PT4MakerNetX.pas
File ..\bin\Lib\Speech.pas
File ..\bin\Lib\__RedirectIOMode.vb
File ..\bin\Lib\VBSystem.vb
@ -247,6 +248,7 @@
${AddFile} "ClientServer.pas"
${AddFile} "OpenGL.pas"
${AddFile} "PT4MakerNetX.pas"
${AddFile} "Speech.pas"
${AddFile} "__RedirectIOMode.vb"
${AddFile} "VBSystem.vb"
@ -255,8 +257,6 @@
Call NGEN
Push "SyntaxVisitors.dll"
Call NGEN
Push "YieldConversionSyntax.dll"
Call NGEN
; SetOutPath "$INSTDIR\Output"
SectionEnd

View file

@ -166,7 +166,12 @@ namespace PascalABCCompiler.SemanticTree
{
get;
}
bool is_nullable_type
{
get;
}
type_special_kind type_special_kind
{
get;

Binary file not shown.

View file

@ -1,4 +1,5 @@
public <#NodeName#>(<#ListElementType#> elem, SourceContext sc = null)
{
Add(elem, sc);
FillParentsInDirectChilds();
}

View file

@ -1,6 +1,8 @@
public <#NodeName#> Add(<#ListElementType#> elem, SourceContext sc = null)
{
<#ListName#>.Add(elem);
if (elem != null)
elem.Parent = this;
if (sc != null)
source_context = sc;
return this;
@ -9,16 +11,23 @@ public <#NodeName#> Add(<#ListElementType#> elem, SourceContext sc = null)
public void AddFirst(<#ListElementType#> el)
{
<#ListName#>.Insert(0, el);
FillParentsInDirectChilds();
}
public void AddFirst(IEnumerable<<#ListElementType#>> els)
{
<#ListName#>.InsertRange(0, els);
foreach (var el in els)
if (el != null)
el.Parent = this;
}
public void AddMany(params <#ListElementType#>[] els)
{
<#ListName#>.AddRange(els);
foreach (var el in els)
if (el != null)
el.Parent = this;
}
private int FindIndexInList(<#ListElementType#> el)
@ -32,21 +41,31 @@ private int FindIndexInList(<#ListElementType#> el)
public void InsertAfter(<#ListElementType#> el, <#ListElementType#> newel)
{
<#ListName#>.Insert(FindIndexInList(el) + 1, newel);
if (newel != null)
newel.Parent = this;
}
public void InsertAfter(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
{
<#ListName#>.InsertRange(FindIndexInList(el) + 1, newels);
foreach (var newel in newels)
if (el != null)
el.Parent = this;
}
public void InsertBefore(<#ListElementType#> el, <#ListElementType#> newel)
{
<#ListName#>.Insert(FindIndexInList(el), newel);
if (newel != null)
newel.Parent = this;
}
public void InsertBefore(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
{
<#ListName#>.InsertRange(FindIndexInList(el), newels);
foreach (var newel in newels)
if (el != null)
el.Parent = this;
}
public bool Remove(<#ListElementType#> el)
@ -57,6 +76,8 @@ public bool Remove(<#ListElementType#> el)
public void ReplaceInList(<#ListElementType#> el, <#ListElementType#> newel)
{
<#ListName#>[FindIndexInList(el)] = newel;
if (newel != null)
newel.Parent = this;
}
public void ReplaceInList(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
@ -64,6 +85,9 @@ public void ReplaceInList(<#ListElementType#> el, IEnumerable<<#ListElementType#
var ind = FindIndexInList(el);
<#ListName#>.RemoveAt(ind);
<#ListName#>.InsertRange(ind, newels);
foreach (var newel in newels)
if (el != null)
el.Parent = this;
}
public int RemoveAll(Predicate<<#ListElementType#>> match)

View file

@ -2358,7 +2358,7 @@ namespace PascalABCCompiler.SyntaxTree
public void read_format_expr(format_expr _format_expr)
{
read_expression(_format_expr);
read_addressed_value(_format_expr);
_format_expr.expr = _read_node() as expression;
_format_expr.format1 = _read_node() as expression;
_format_expr.format2 = _read_node() as expression;
@ -3716,7 +3716,7 @@ namespace PascalABCCompiler.SyntaxTree
public void read_tuple_node(tuple_node _tuple_node)
{
read_expression(_tuple_node);
read_addressed_value(_tuple_node);
_tuple_node.el = _read_node() as expression_list;
}

View file

@ -3415,7 +3415,7 @@ namespace PascalABCCompiler.SyntaxTree
public void write_format_expr(format_expr _format_expr)
{
write_expression(_format_expr);
write_addressed_value(_format_expr);
if (_format_expr.expr == null)
{
bw.Write((byte)0);
@ -5787,7 +5787,7 @@ namespace PascalABCCompiler.SyntaxTree
public void write_tuple_node(tuple_node _tuple_node)
{
write_expression(_tuple_node);
write_addressed_value(_tuple_node);
if (_tuple_node.el == null)
{
bw.Write((byte)0);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ namespace PascalABCCompiler.SyntaxTreeConverters
{
// Прошивание ссылками на Parent nodes. Должно идти первым
// FillParentNodeVisitor расположен в SyntaxTree/tree как базовый визитор, отвечающий за построение дерева
FillParentNodeVisitor.New.ProcessNode(root);
//FillParentNodeVisitor.New.ProcessNode(root);
// Выносим выражения с лямбдами из заголовка foreach
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);

View file

@ -155,8 +155,8 @@ namespace SyntaxVisitors.SugarVisitors
public override void visit(dot_question_node dqn)
{
var sug = ConvertToQCE1(dqn);
ReplaceUsingParent(dqn, sug);
visit(sug);
ReplaceUsingParent(dqn, sug);
}
}
}

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
/// Модуль содержит шаблоны классов
/// Stack — стек
/// Queue — очередь
@ -7,12 +9,6 @@
/// LinkedList — двусвязный список
unit Collections;
//------------------------------------------------------------------------------
// Модуль упрощенных классов коллекций для обучения
// Версия 1.0
// Copyright (c) 2009 Белякова Ю., Михалкович С.С., Саатчи А.
//------------------------------------------------------------------------------
interface
// -------------------------------- SingleNode ---------------------------------

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//Для совместимости с Pascal ABC
unit Colors;
end.

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
unit DMZadan;
interface

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
// Для совместимости с Pascal ABC
unit Events;
end.

View file

@ -1,5 +1,5 @@
// (c) Mikst, Juliet 2010
/// Системный модуль для языка Oberon
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
unit Oberon00System;
interface

View file

@ -89,13 +89,13 @@ type
/// Базовый тип исключений
Exception = System.Exception;
/// type double = real
/// double = real
double = System.Double;
/// type longint = integer
/// longint = integer
longint = System.Int32;
/// type cardinal = longword
/// cardinal = longword
cardinal = System.UInt32;
/// Представляет 128-битное вещественное число
@ -117,6 +117,7 @@ type
/// Представляет базовый класс для реализации интерфейса IComparer
Comparer<T> = System.Collections.Generic.Comparer<T>;
/// Представляет базовый класс для реализации интерфейса IComparer
IComparable<T> = System.IComparable<T>;
/// Представляет множество значений, реализованное на базе хеш-таблицы
@ -6310,7 +6311,7 @@ end;
// -----------------------------------------------------
function PascalABCVersion: string;
begin
Result := '3.2.0.1364';
Result := '3.2.0.1364'{PABC_VERSION};
end;
function ParamCount: integer;
@ -8913,6 +8914,7 @@ begin
Result := Self.GetLength(1);
end;
/// Вывод двумерного массива, w - ширина поля вывода
function Print<T>(Self: array [,] of T; w: integer := 4): array [,] of T; extensionmethod;
begin
for var i:=0 to Self.RowCount-1 do
@ -8928,6 +8930,7 @@ begin
Result := Self;
end;
/// Вывод двумерного вещественного массива по формату :w:f
function Print(Self: array [,] of real; w: integer := 7; f: integer := 2): array [,] of real; extensionmethod;
begin
for var i:=0 to Self.RowCount-1 do
@ -8939,12 +8942,14 @@ begin
Result := Self;
end;
/// Вывод двумерного массива и переход на следующую строку, w - ширина поля вывода
function Println<T>(Self: array [,] of T; w: integer := 4): array [,] of T; extensionmethod;
begin
Self.Print(w);
Result := Self;
end;
/// Вывод двумерного вещественного массива по формату :w:f и переход на следующую строку
function Println(Self: array [,] of real; w: integer := 7; f: integer := 2): array [,] of real; extensionmethod;
begin
Self.Print(w,f);
@ -9080,6 +9085,9 @@ begin
Self[i,j] := f(i,j);
end;
// -----------------------------------------------------
//>> Фиктивная секция YYY - не удалять! # YYY
// -----------------------------------------------------
// Реализация операций с матрицами - только после введения RowCount и ColCount
function MatrRandom(m: integer; n: integer; a,b: integer): array [,] of integer;
@ -9148,6 +9156,42 @@ begin
Result[i,j] := ReadReal;
end;
// -----------------------------------------------------
//>> Фиктивная секция XXX - не удалять! # XXX
// -----------------------------------------------------
type
AdjGroupClass<T> = class
private
cur: T;
enm: IEnumerator<T>;
fin: boolean;
public
constructor Create(a: sequence of T);
begin
enm := a.GetEnumerator();
fin := enm.MoveNext;
if fin then
cur := enm.Current;
end;
function TakeGroup: sequence of T;
begin
yield cur;
fin := enm.movenext;
while fin do
begin
if enm.current = cur then
yield enm.current
else
begin
cur := enm.Current;
break;
end;
fin := enm.movenext;
end;
end;
end;
// -----------------------------------------------------
//>> Методы расширения типа array of T # Extension methods for array of T
// -----------------------------------------------------
@ -9189,40 +9233,6 @@ begin
end;
end;
///--
type
AdjGroupClass<T> = class
private
cur: T;
enm: IEnumerator<T>;
fin: boolean;
public
constructor Create(a: sequence of T);
begin
enm := a.GetEnumerator();
fin := enm.MoveNext;
if fin then
cur := enm.Current;
end;
function TakeGroup: sequence of T;
begin
yield cur;
fin := enm.movenext;
while fin do
begin
if enm.current = cur then
yield enm.current
else
begin
cur := enm.Current;
break;
end;
fin := enm.movenext;
end;
end;
end;
/// Группирует одинаковые подряд идущие элементы, получая последовательность последовательностей
function AdjacentGroup<T>(Self: sequence of T): sequence of sequence of T; extensionmethod;
begin
@ -9231,7 +9241,7 @@ begin
yield c.TakeGroup();
end;
//ToDo Сделать AdjacentGroup с функцией сравнения
// ToDo Сделать AdjacentGroup с функцией сравнения
/// Возвращает минимальный элемент
function Min<T>(Self: array of T): T; extensionmethod; where T: System.IComparable<T>;
@ -9287,7 +9297,6 @@ begin
Result := Self[i];
end;
/// Возвращает индекс первого минимального элемента начиная с позиции start
function IndexMin<T>(Self: array of T; start: integer := 0): integer; extensionmethod; where T: System.IComparable<T>;
begin
@ -9388,7 +9397,6 @@ begin
Self[i] := f(i);
end;
/// Выполняет бинарный поиск в отсортированном массиве
function BinarySearch<T>(self: array of T; x: T): integer; extensionmethod;
begin

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
unit PointRect;
//Для совместимости с Pascal ABC

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
unit RobotZadan;
interface

View file

@ -1,5 +1,5 @@
#reference 'System.Windows.Forms.dll'
#reference 'System.Drawing.dll'
{$reference 'System.Windows.Forms.dll'}
{$reference 'System.Drawing.dll'}
uses System, System.Windows.Forms;

View file

@ -1,5 +1,5 @@
#reference 'System.Windows.Forms.dll'
#reference 'System.Drawing.dll'
{$reference 'System.Windows.Forms.dll'}
{$reference 'System.Drawing.dll'}
uses System, System.Windows.Forms;

16
TestSuite/exceptions2.pas Normal file
View file

@ -0,0 +1,16 @@
type
MyException1 = class(Exception);
MyException2 = class(Exception);
IncorrectInputException = class(Exception);
begin
var s := '';
try
raise new MyException1('EXCEPTION2!!');
except
on e: IncorrectInputException do writeln(e.Message);
on e: MyException1 do s := e.Message;
on e: MyException2 do writeln(e.Message);
end;
assert(s = 'EXCEPTION2!!');
end.

9
TestSuite/generics12.pas Normal file
View file

@ -0,0 +1,9 @@
function DQNToNullable<T>(v: T): T; where T: record;
begin
var res := new System.Nullable<T>(v);
Result := res.Value;
end;
begin
assert(DQNToNullable(2) = 2);
end.

View file

@ -0,0 +1,14 @@
type
c1 = class
seq1: sequence of integer;
constructor create;
begin
var a := Arr(3.1, 3.7);
seq1 := a.Select(b -> Round(b));
end;
end;
begin
var obj := new c1;
assert(obj.seq1.ToArray[1] = 4);
end.

172
TestSuite/nullable.pas Normal file
View file

@ -0,0 +1,172 @@
type TRec = record
a: integer;
b: real;
end;
type TClass = class
v1: System.Nullable<integer>;
v2: System.Nullable<TRec>;
constructor;
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
procedure Test(v1 : System.Nullable<integer>; v2: System.Nullable<TRec>);
begin
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
end;
type TClass2 = class
class v1: System.Nullable<integer>;
class v2: System.Nullable<TRec>;
class procedure Test;
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
class procedure Test2(v1 : System.Nullable<integer>; v2: System.Nullable<TRec>);
begin
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
end;
procedure Test3(v1 : System.Nullable<integer>; v2: System.Nullable<TRec>);
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
procedure Test4(var v1 : System.Nullable<integer>; var v2: System.Nullable<TRec>);
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
procedure Test2;
begin
var v1 : System.Nullable<integer>;
var v2 : System.Nullable<TRec>;
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
procedure Test;
var
v1 : System.Nullable<integer>;
v2 : System.Nullable<TRec>;
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
procedure Test6;
var
v1 : System.Nullable<integer>;
v2 : System.Nullable<TRec>;
procedure Nested;
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
begin
Nested;
end;
procedure Test5(v1 : System.Nullable<integer>; v2: System.Nullable<TRec>);
begin
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
end;
var
v1 : System.Nullable<integer>;
v2 : System.Nullable<TRec>;
begin
v1 := nil;
assert(v1 = nil);
v1 := 4;
assert(v1 <> nil);
v2 := nil;
assert(v2 = nil);
v2 := new TRec;
assert(v2 <> nil);
Test;
Test2;
var obj := new TClass;
obj.Test(nil, nil);
TClass2.Test;
Test3(v1, v2);
Test4(v1, v2);
v1 := nil;
v2 := nil;
Test5(v1, v2);
Test6;
Test5(nil, nil);
TClass2.Test2(nil, nil);
var arr: array of System.Nullable<integer>;
SetLength(arr,3);
arr[0] := nil;
assert(arr[0] = nil);
arr[0] := 2;
assert(arr[0] <> nil);
end.

View file

@ -2,15 +2,28 @@ begin
var b: byte := 2;
var i: integer := 3;
var s: shortint := 4;
var sm: smallint := 1;
var w: word := 5;
var lw: longword := 6;
var i64: int64 := 7;
var ui64: uint64 := 8;
assert(min(b,i)=2);
assert(min(s,i)=3);
assert(min(s,sm)=1);
assert(min(w,s)=4);
assert(min(b,lw)=2);
assert(min(i,lw)=3);
assert(min(s,lw)=4);
assert(min(b,s)=2);
assert(min(b,i64)=2);
assert(min(i64,ui64)=7);
assert(min(b,255)=2);
assert(min(s,255)=4);
assert(min(sm,65535)=1);
assert(min(i,255)=3);
assert(min(w,65535)=5);
assert(min(lw,255)=6);
assert(min(i64,255)=7);
assert(min(ui64,255)=8);
end.

View file

@ -0,0 +1,18 @@
unit u_exceptions2;
type
MyException1 = class(Exception);
MyException2 = class(Exception);
IncorrectInputException = class(Exception);
begin
var s := '';
try
raise new MyException1('EXCEPTION2!!');
except
on e: IncorrectInputException do writeln(e.Message);
on e: MyException1 do s := e.Message;
on e: MyException2 do writeln(e.Message);
end;
assert(s = 'EXCEPTION2!!');
end.

View file

@ -0,0 +1,31 @@
unit u_explicitinterface;
type
IEnr = System.Collections.IEnumerator;
IEnb = System.Collections.IEnumerable;
var a : integer;
type My = class(IEnumerable<integer>)
public
function IEnb.GetEnumerator(): IEnr;
begin
a := 1;
end;
function GetEnumerator(): IEnumerator<integer>;
begin
a := 2;
end;
end;
begin
var ien: IEnb := new My;
ien.GetEnumerator;
assert(a=1);
var ien2: IEnumerable<integer> := new My;
ien2.GetEnumerator;
assert(a=2);
a := 0;
var mc := new My;
mc.GetEnumerator();
assert(a=2);
end.

View file

@ -0,0 +1,18 @@
unit u_interface1;
type IInt1 = interface
function Test: integer;
end;
TClass = class(IInt1)
public function Test: integer;
begin
Result := 3;
end;
end;
var obj : IInt1;
begin
obj := new TClass;
assert(obj.Test=3);
end.

View file

@ -0,0 +1,30 @@
unit u_interface2;
type TClass<T> = class(IEnumerable<T>)
public function GetEnumerator: IEnumerator<T>;
begin
end;
public function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator;
begin
end;
end;
procedure Test;
begin
var i := 1;
var seq1 := i.Iterate(x->x+1);
var lst := new List<integer>;
foreach var j in seq1 do
begin
lst += j;
if j > 10 then
break;
end;
assert(lst[5] = 6);
end;
begin
Test;
end.

View file

@ -0,0 +1,15 @@
unit u_interface3;
type TClass<T> = class(IEnumerable<T>)
public function System.Collections.Generic.IEnumerable<T>.GetEnumerator: IEnumerator<T>;
begin
end;
public function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator;
begin
end;
end;
begin
end.

View file

@ -0,0 +1,31 @@
unit u_interface4;
type
IEnr = System.Collections.IEnumerator;
IEnb = System.Collections.IEnumerable;
var a : integer;
type My = class(IEnumerable<integer>)
public
function IEnb.GetEnumerator(): IEnr;
begin
a := 1;
end;
function System.Collections.Generic.IEnumerable<integer>.GetEnumerator(): IEnumerator<integer>;
begin
a := 2;
end;
end;
begin
var ien: IEnb := new My;
ien.GetEnumerator;
assert(a=1);
var ien2: IEnumerable<integer> := new My;
ien2.GetEnumerator;
assert(a=2);
a := 0;
var mc := new My;
mc.GetEnumerator();
assert(a=2);
end.

View file

@ -0,0 +1 @@
uses u_exceptions2; begin end.

View file

@ -0,0 +1 @@
uses u_explicitinterface; begin end.

View file

@ -0,0 +1 @@
uses u_interface1; begin end.

View file

@ -0,0 +1 @@
uses u_interface2; begin end.

View file

@ -0,0 +1 @@
uses u_interface3; begin end.

View file

@ -0,0 +1 @@
uses u_interface4; begin end.

View file

@ -460,30 +460,10 @@ namespace PascalABCCompiler.TreeConverter
public SymbolInfoList(SymbolInfoUnit inf)
{
if (inf == null)
{
Console.Write("vse ploho");
}
InfoUnitList = new List<SymbolInfoUnit>(SymbolTable.SymbolTableConstants.InfoList_StartSize);
InfoUnitList.Add(inf);
}
/*public SymbolInfoList(SymbolInfo inf)
{
if (inf == null)
{
Console.Write("vse ploho");
}
InfoUnitList = new List<SymbolInfoUnit>(SymbolTable.SymbolTableConstants.InfoList_StartSize);
while (inf != null)
{
SymbolInfoUnit temp = new SymbolInfoUnit(inf);
InfoUnitList.Add(temp);
inf = inf.Next;
}
}*/
public SymbolInfoList copy()
{
SymbolInfoList si = new SymbolInfoList();
@ -526,18 +506,6 @@ namespace PascalABCCompiler.TreeConverter
return -1;
}
/*public SymbolInfo ToSymbolInfo()
{
SymbolInfo first_temp = new SymbolInfo();
SymbolInfo temp = first_temp;
foreach(var info_unit in InfoUnitList)
{
temp.Next = info_unit.ToSymbolInfo();
temp = temp.Next;
}
return first_temp.Next;
}*/
public static bool operator ==(SymbolInfoList a, SymbolInfoList b)
{
if (System.Object.ReferenceEquals(a, b))
@ -636,25 +604,6 @@ namespace PascalABCCompiler.TreeConverter
return si;
}
/*public SymbolInfo ToSymbolInfo()
{
reference.Next = null;
reference.access_level = _access_level;
reference.symbol_kind = _symbol_kind;
reference.sym_info = _sym_info;
reference.scope = scope;
return reference;
}*/
/*public SymbolInfoUnit(SymbolInfo inf)
{
//reference = inf;
_access_level = inf.access_level;
_symbol_kind = inf.symbol_kind;
_sym_info = inf.sym_info;
scope = inf.scope;
}*/
private symbol_kind get_function_kind(function_node fn, bool is_overload)
{
symbol_kind sk;

View file

@ -309,6 +309,7 @@ namespace PascalABCCompiler.SystemLibrary
public static UnitDefinitionItem OMP_Available;
public static UnitDefinitionItem OMP_ParallelFor;
public static UnitDefinitionItem OMP_ParallelSections;
public static UnitDefinitionItem PascalABCVersion;
//native-->
public static UnitDefinitionItem ObjectType;
public static UnitDefinitionItem StringType;

View file

@ -278,7 +278,12 @@ namespace PascalABCCompiler.TreeConverter
{
syntax_tree_visitor.AddError(loc, ErrString, values);
}
internal bool can_call_inherited_ctor_call(statements_list lst)
{
return lst.statements.Count == 0;
}
public void reset()
{
_cmn = null;
@ -1183,8 +1188,7 @@ namespace PascalABCCompiler.TreeConverter
{
common_function_node top_func = _func_stack.top();
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateScope(top_func.scope);
common_in_function_function_node ciffn;
ciffn=new common_in_function_function_node(name,def_loc,top_func,scope);
common_in_function_function_node ciffn =new common_in_function_function_node(name,def_loc,top_func,scope);
top_func.functions_nodes_list.AddElement(ciffn);
_last_created_function = new SymbolInfoUnit(ciffn);
if (add_symbol_info)
@ -1656,7 +1660,7 @@ namespace PascalABCCompiler.TreeConverter
return cf;
}
public var_definition_node add_var_definition(string name, location loc, type_node tn, SemanticTree.polymorphic_state ps)
public var_definition_node add_var_definition(string name, location loc, type_node tn, SemanticTree.polymorphic_state ps, bool not_add_to_varlist=false)
{
check_name_free(name,loc);
var_definition_node vdn=null;
@ -1684,6 +1688,7 @@ namespace PascalABCCompiler.TreeConverter
}
local_block_variable lv = new local_block_variable(name, tn, CurrentStatementList, loc);
CurrentScope.AddSymbol(name, new SymbolInfoUnit(lv));
if (!not_add_to_varlist)
lv.block.local_variables.Add(lv);
if (tn == null) //Тип еще неизвестен, будем закрывать.
var_defs.Add(lv);
@ -2894,7 +2899,6 @@ namespace PascalABCCompiler.TreeConverter
/// </summary>
/// <param name="fn">Проверяемая функция</param>
/// <returns></returns>
//DeleteSymbolInfo
private bool check_unique_or_predefined(common_function_node fn)
{
SymbolInfoList si_list = null;

View file

@ -411,6 +411,7 @@ namespace PascalABCCompiler.TreeConverter
public static string PointerToStringFunction_func_name = "PointerToString";
public static string GetRuntimeSizeFunction_func_name = "GetRuntimeSize";
public static string StrProcedure_func_name = "Str";
public static string PascalABCVersion_func_name = "PascalABCVersion";
public static string ChrUnicodeFunction_func_name = "ChrUnicode";
public static string ExceptionName = "System.Exception";
public static string value_in_accessor_name = "$value";

View file

@ -100,7 +100,12 @@ namespace PascalABCCompiler.TreeConverter
{
return statement_list_stack.pop();
}
internal statements_list statement_list_stack_first()
{
return statement_list_stack.first();
}
public type_constructor type_constructor
{
get
@ -436,7 +441,7 @@ namespace PascalABCCompiler.TreeConverter
common_constructor_call ccc = new common_constructor_call((common_method_node)fn, loc);
//(ssyy) По-видимому, здесь всегда можно присваивать false, так как при создании нового объекта мы сюда не заходим...
ccc._new_obj_awaited = false;
if (!syntax_tree_visitor.context.allow_inherited_ctor_call)
if (!syntax_tree_visitor.context.allow_inherited_ctor_call && !syntax_tree_visitor.context.can_call_inherited_ctor_call(statement_list_stack_first()))
{
if (syntax_tree_visitor.inherited_ident_processing)
syntax_tree_visitor.AddError(new SimpleSemanticError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST"));
@ -490,7 +495,7 @@ namespace PascalABCCompiler.TreeConverter
compiled_constructor_call ccc = new compiled_constructor_call(ccn, loc);
ccc.parameters.AddRange(exprs);
ccc._new_obj_awaited = false;
if (!syntax_tree_visitor.context.allow_inherited_ctor_call)
if (!syntax_tree_visitor.context.allow_inherited_ctor_call && !syntax_tree_visitor.context.can_call_inherited_ctor_call(statement_list_stack_first()))
{
throw new SimpleSemanticError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
}
@ -2009,13 +2014,26 @@ namespace PascalABCCompiler.TreeConverter
else
{
type_compare tc = type_table.compare_types(best_function.return_value_type, fn.return_value_type);
if (tc == type_compare.greater_type)
if (best_function.return_value_type.is_standard_type && fn.return_value_type.is_standard_type)
{
to_remove.Add(best_function);
best_function = fn;
if (tc == type_compare.less_type)
{
to_remove.Add(best_function);
best_function = fn;
}
else if (tc == type_compare.greater_type)
to_remove.Add(fn);
}
else
{
if (tc == type_compare.greater_type)
{
to_remove.Add(best_function);
best_function = fn;
}
else if (tc == type_compare.less_type)
to_remove.Add(fn);
}
else if (tc == type_compare.less_type)
to_remove.Add(fn);
}
}
}

View file

@ -98,6 +98,7 @@ namespace PascalABCCompiler.TreeConverter
internal void RemoveLastError()
{
if (ErrorsList.Count > 0)
ErrorsList.RemoveAt(ErrorsList.Count - 1);
}
@ -284,6 +285,7 @@ namespace PascalABCCompiler.TreeConverter
SystemLibrary.SystemLibInitializer.ObjectType = null;
SystemLibrary.SystemLibInitializer.StringType = null;
SystemLibrary.SystemLibInitializer.ConfigVariable = null;
SystemLibrary.SystemLibInitializer.PascalABCVersion = null;
}
internal bool SystemUnitAssigned = false;
@ -359,6 +361,7 @@ namespace PascalABCCompiler.TreeConverter
SystemLibrary.SystemLibInitializer.PointerToStringFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.PointerToStringFunction_func_name);
SystemLibrary.SystemLibInitializer.GetRuntimeSizeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.GetRuntimeSizeFunction_func_name);
SystemLibrary.SystemLibInitializer.StrProcedure = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.StrProcedure_func_name);
SystemLibrary.SystemLibInitializer.PascalABCVersion = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.PascalABCVersion_func_name);
SystemLibrary.SystemLibInitializer.ChrUnicodeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.ChrUnicodeFunction_func_name);
SystemLibrary.SystemLibInitializer.AssertProcedure = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.AssertProcedure);
SystemLibrary.SystemLibInitializer.CheckRangeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.check_in_range);
@ -452,6 +455,7 @@ namespace PascalABCCompiler.TreeConverter
SystemLibrary.SystemLibInitializer.PointerToStringFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.PointerToStringFunction_func_name);
SystemLibrary.SystemLibInitializer.GetRuntimeSizeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.GetRuntimeSizeFunction_func_name);
SystemLibrary.SystemLibInitializer.StrProcedure = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.StrProcedure_func_name);
SystemLibrary.SystemLibInitializer.PascalABCVersion = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.PascalABCVersion_func_name);
SystemLibrary.SystemLibInitializer.ChrUnicodeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.ChrUnicodeFunction_func_name);
SystemLibrary.SystemLibInitializer.AssertProcedure = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.AssertProcedure);
SystemLibrary.SystemLibInitializer.CheckRangeFunction = new SystemLibrary.UnitDefinitionItem(psystem_unit, compiler_string_consts.check_in_range);
@ -999,14 +1003,17 @@ namespace PascalABCCompiler.TreeConverter
expressions_list pars = new expressions_list();
pars.AddElement(expr);
bool tmp = ThrowCompilationError;
ThrowCompilationError = false;
function_node fn;
fn = convertion_data_and_alghoritms.select_function(pars, si, loc);
expr = pars[0];
ThrowCompilationError = tmp;
if (fn == null)
{
RemoveLastError();
AddError(new OperatorCanNotBeAppliedToThisType(name, expr));
}
expr = pars[0];
#if (DEBUG)
convertion_data_and_alghoritms.check_operator(fn);
#endif
@ -1169,8 +1176,7 @@ namespace PascalABCCompiler.TreeConverter
}
}
}
var temp = new SymbolInfoUnit(fnode);
si.Add(temp);
si.Add(new SymbolInfoUnit(fnode));
}
}
else
@ -1771,24 +1777,17 @@ namespace PascalABCCompiler.TreeConverter
}
current_catch_excep = new int_const_node(2,null);//create_constructor_call(filter_type, new expressions_list(), null);
local_block_variable_reference lvr = null;
statements_list sl = new statements_list(get_location(eh.statements));
convertion_data_and_alghoritms.statement_list_stack_push(sl);
context.enter_code_block_without_bind();
if (eh.variable != null)
{
context.check_name_redefinition = false;
local_block_variable lbv = context.add_var_definition(eh.variable.name, get_location(eh.variable), filter_type, SemanticTree.polymorphic_state.ps_common) as local_block_variable;
context.check_name_redefinition = true;
local_block_variable lbv = context.add_var_definition(eh.variable.name, get_location(eh.variable), filter_type, SemanticTree.polymorphic_state.ps_common, true) as local_block_variable;
lvr = new local_block_variable_reference(lbv, lbv.loc);
}
statement_node stm = convert_strong(eh.statements);
context.leave_code_block();
/*if (eh.variable != null)
{
context.leave_scope();
}*/
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
exception_filter ef = new exception_filter(filter_type, lvr, stm, get_location(eh));
efl.AddElement(ef);
current_catch_excep = null;
@ -5982,6 +5981,11 @@ namespace PascalABCCompiler.TreeConverter
{
is_format_allowed = true;
}
else if (SystemLibrary.SystemLibInitializer.PascalABCVersion.Equal(si))
{
return_value(new string_const_node(RevisionClass.FullVersion, get_location(_method_call)));
return;
}
else if (SystemLibrary.SystemLibInitializer.ArrayCopyFunction.Equal(si))
{
if (_method_call.parameters != null && _method_call.parameters.expressions.Count == 1)
@ -8331,9 +8335,9 @@ namespace PascalABCCompiler.TreeConverter
lab.comprehensive_code_block = context.block_stack.Peek();
foreach (goto_statement gs in lab.goto_statements)
{
if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block))
if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block) && gs.location != null)
{
//AddError(gs.location, "BLOCKED_LABEL_{0}_GOTO", lab.name);
AddError(gs.location, "BLOCKED_LABEL_{0}_GOTO", lab.name);
}
}
convertion_data_and_alghoritms.check_node_parser_error(_labeled_statement.to_statement);
@ -8363,9 +8367,9 @@ namespace PascalABCCompiler.TreeConverter
lab.goto_statements.Add(gs);
if (lab.comprehensive_code_block != null)
{
if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block))
if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block) && _goto_statement.source_context != null)
{
//AddError(gs.location, "BLOCKED_LABEL_{0}_GOTO", lab.name);
AddError(gs.location, "BLOCKED_LABEL_{0}_GOTO", lab.name);
}
}
ret.return_value((statement_node)gs);
@ -15194,7 +15198,10 @@ namespace PascalABCCompiler.TreeConverter
{
//return convertion_data_and_alghoritms.create_full_function_call(new expressions_list(),
// si,lloc,blocks.converted_type,blocks.top_function,false);
if (SystemUnitAssigned && SystemLibrary.SystemLibInitializer.PascalABCVersion.Equal(si))
{
return new string_const_node(RevisionClass.FullVersion, get_location(_ident));
}
if (si.First().sym_info == SystemLibrary.SystemLibInitializer.NewProcedure.sym_info)
{
AddError(lloc, "EXPECTED_TYPE_AFTER_NEW");
@ -15491,7 +15498,7 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
if (!context.allow_inherited_ctor_call)
if (!context.allow_inherited_ctor_call && !context.can_call_inherited_ctor_call(convertion_data_and_alghoritms.statement_list_stack_first()))
AddError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
expressions_list exprs = new expressions_list();
foreach (common_parameter cp in cfn.parameters)
@ -16314,31 +16321,17 @@ namespace PascalABCCompiler.TreeConverter
convertion_data_and_alghoritms.statement_list_stack_push(stl);
for (var i=0; i< _statement_list.subnodes.Count; i++) // SSM 13.10.16 - поменял т.к. собираюсь менять узлы в процессе обхода
//foreach (statement syntax_statement in _statement_list.subnodes)
{
statement syntax_statement = _statement_list.subnodes[i];
try
{
// SSM выкинул эти три строки - теперь внутриблочные описания обрабатываются как обычные операторы.
// При этом в конце visit(var_statement) стоит вызов ret.reset(), который возвращает нулевой semantic_statement - и всё работает эквивалентно
//if (syntax_statement is SyntaxTree.var_statement)
// visit(syntax_statement as SyntaxTree.var_statement); // Добавление в текущий statements_list происходит опосредованно !!
//else if (MustVisitBody) // MustVisitBody - всегда True!!!
//{
//(ssyy) TODO Сделать по-другому!!!
statement_node semantic_statement = convert_strong(syntax_statement);
//(ssyy) Проверка для C
if (semantic_statement != null)
{
//Обработать по другому - комментарий не мой - SSM
//if (context.CurrentScope.AddStatementsToFront)
// stl.statements.AddElementFirst(semantic_statement);
//else
stl.statements.AddElement(semantic_statement);
}
context.allow_inherited_ctor_call = false;
//}
}
catch (Errors.Error ex)
{

View file

@ -148,14 +148,14 @@ namespace PascalABCCompiler.TreeRealization
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_REFERENCE_TYPE", tn.PrintableName);
}
if (gpe.is_value && !tn.is_value)
if (gpe.is_value && !tn.is_value && !tn.is_generic_parameter)
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_VALUE_TYPE", tn.PrintableName);
}
if (gpe.base_class != null && gpe.base_class != SystemLibrary.SystemLibrary.object_type)
{
type_node base_type = generic_convertions.determine_type(gpe.base_class, tparams, method_param_types);
if (base_type != tn && !type_table.is_derived(base_type, tn))
if (base_type != tn && !type_table.is_derived(base_type, tn) && !tn.is_generic_parameter)
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_DERIVED_FROM_{1}", tn.PrintableName, base_type.name);
}

View file

@ -282,6 +282,10 @@ namespace PascalABCCompiler.TreeRealization
{
return true;
}
else if (tn.is_nullable_type)
{
return true;
}
else
{
return !tn.is_value || tn is null_type_node;

View file

@ -53,7 +53,9 @@ namespace PascalABCCompiler.TreeRealization
}
*/
internal bool is_ref_inited;
internal bool is_nullable_inited;
private bool _is_nullable_type;
public virtual bool IsSealed
{
get { return false; }
@ -64,6 +66,27 @@ namespace PascalABCCompiler.TreeRealization
get { return false; }
}
public virtual bool is_standard_type
{
get { return false; }
}
public bool is_nullable_type
{
get
{
if (is_nullable_inited)
return _is_nullable_type;
string fname = full_name;
if (this is compiled_type_node)
_is_nullable_type = fname != null && fname.StartsWith("System.Nullable");
else if (original_generic != null)
return original_generic.is_nullable_type;
is_nullable_inited = true;
return _is_nullable_type;
}
}
public virtual bool IsInterface
{
get
@ -1731,7 +1754,7 @@ namespace PascalABCCompiler.TreeRealization
public override string full_name {
get
{
if (!string.IsNullOrEmpty(_comprehensive_namespace.namespace_name))
if (_comprehensive_namespace != null && !string.IsNullOrEmpty(_comprehensive_namespace.namespace_name))
return _comprehensive_namespace.namespace_name+"."+_name;
return _name;
}
@ -2528,7 +2551,15 @@ namespace PascalABCCompiler.TreeRealization
{
}
}
public override bool is_standard_type
{
get
{
return NetHelper.NetHelper.IsStandType(_compiled_type);
}
}
public override function_node generic_function_container
{
get
@ -3979,7 +4010,18 @@ namespace PascalABCCompiler.TreeRealization
}
}
public override string name {
get {
return "nil";
}
}
public override string full_name {
get {
return "nil";
}
}
}
public class convert_function_to_function_call

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace PascalABCCompiler.SyntaxTree
{
public class ExecuteVisitor:AbstractVisitor

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View file

@ -1,4 +1,6 @@
using System.Reflection;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@ -10,7 +12,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("NodeCounter")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyCopyright("Copyright © Ivan Bondarev, Stanislav Mihalkovich")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class AboutBox
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Reflection;
using System.Runtime.CompilerServices;
@ -11,7 +13,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyCopyright("Copyright (c) Ivan Bondarev, Stanislav Mihalkovich")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Collections.Generic;

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class FilterTagsCollection
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
using System.Collections;

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class GlobalRenamer
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class GrammarBrowser
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -1,3 +1,5 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using NodesGenerator.XmlModel;
using System;
using System.Collections;
@ -8,6 +10,7 @@ using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace NodeGenerator
@ -711,6 +714,19 @@ namespace NodeGenerator
writer.CloseBlock();
}
public virtual void generate_parent_filler(NodeWriter writer)
{
writer.WriteLine($"if ({field_name} != null)");
writer.Indent++;
writer.WriteLine($"{field_name}.Parent = this;");
writer.Indent--;
}
public virtual void generate_parent_filler_call(NodeWriter writer)
{
writer.WriteLine($"{field_name}?.FillParentsInAllChilds();");
}
/// <summary>
/// Получает эквивалент поля для модели XML
/// </summary>
@ -889,7 +905,37 @@ namespace NodeGenerator
writer.WriteLine($"{destination} = {field_name};");
}
public override SyntaxField XmlField()
public override void generate_parent_filler(NodeWriter writer)
{
if (list_type != "")
{
writer.WriteLine($"if ({field_name} != null)");
writer.OpenBlock();
writer.WriteLine($"foreach (var child in {field_name})");
writer.Indent++;
writer.WriteLine("if (child != null)");
writer.Indent++;
writer.WriteLine("child.Parent = this;");
writer.Indent -= 2;
writer.CloseBlock();
}
}
public override void generate_parent_filler_call(NodeWriter writer)
{
if (list_type != "")
{
writer.WriteLine($"if ({field_name} != null)");
writer.OpenBlock();
writer.WriteLine($"foreach (var child in {field_name})");
writer.Indent++;
writer.WriteLine("child?.FillParentsInAllChilds();");
writer.Indent--;
writer.CloseBlock();
}
}
public override SyntaxField XmlField()
{
return new ExtendedField(this);
}
@ -1099,6 +1145,8 @@ namespace NodeGenerator
sw.WriteLine(text_consts.tab+text_consts.tab+text_consts.tab+"source_context = sc;");
}
sw.WriteLine(text_consts.tab3 + "FillParentsInDirectChilds();");
sw.WriteLine(text_consts.tab+text_consts.tab+text_consts.close_figure);
//sw.WriteLine();
@ -3240,6 +3288,37 @@ namespace NodeGenerator
}
}
private void generate_fill_parents_in_direct_childs(StreamWriter sw)
{
var writer = new NodeWriter(sw, 2);
string inheritModifier = node_name == "syntax_tree_node" ? "virtual" : "override";
writer.WriteLine("///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>");
writer.WriteLine($"public {inheritModifier} void FillParentsInDirectChilds()");
writer.OpenBlock();
foreach (var nodeFieldInfo in collect_subnodes(true, true, false))
{
nodeFieldInfo.generate_parent_filler(writer);
}
writer.CloseBlock();
}
private void generate_fill_parents_in_all_childs(StreamWriter sw)
{
var writer = new NodeWriter(sw, 2);
string inheritModifier = node_name == "syntax_tree_node" ? "virtual" : "override";
writer.WriteLine("///<summary> Заполняет поля Parent во всем поддереве </summary>");
writer.WriteLine($"public {inheritModifier} void FillParentsInAllChilds()");
writer.OpenBlock();
writer.WriteLine("FillParentsInDirectChilds();");
foreach (var nodeFieldInfo in collect_subnodes(true, true, false))
{
nodeFieldInfo.generate_parent_filler_call(writer);
}
writer.CloseBlock();
}
public void generate_code(StreamWriter sw,HelpStorage hst, SyntaxTemplateManager manager)
{
//sw.WriteLine();
@ -3313,6 +3392,12 @@ namespace NodeGenerator
generate_clone_method(sw);
sw.WriteLine();
generate_fill_parents_in_direct_childs(sw);
sw.WriteLine();
generate_fill_parents_in_all_childs(sw);
sw.WriteLine();
//generate_with_methods(sw);
generate_subnodes_number_property(sw);

View file

@ -76,3 +76,15 @@ G:\MMCS\Programming\PascalABCNET\Utils\NodesGeneratorNew\NodesGenerator_old\obj\
G:\MMCS\Programming\PascalABCNET\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator_old.csproj.GenerateResource.Cache
G:\MMCS\Programming\PascalABCNET\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.exe
G:\MMCS\Programming\PascalABCNET\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.pdb
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\bin\Debug\NodesGenerator.exe.config
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\bin\Debug\NodesGenerator.exe
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\bin\Debug\NodesGenerator.pdb
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.Form1.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.method_editor.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.node_def.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.simple_node_editor.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.subnode_editor.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.template_form.resources
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator_old.csproj.GenerateResource.Cache
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.exe
J:\PascalABC.NET\!PABC_Git\Utils\NodesGeneratorNew\NodesGenerator_old\obj\Debug\NodesGenerator.pdb

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class TagEmForm
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -8,7 +8,7 @@ using System.Xml.Serialization;
namespace NodesGenerator.XmlModel
{
[Serializable]
public class HelpUnit
public class HelpUnit : IComparable<HelpUnit>
{
public HelpUnit() { }
@ -23,6 +23,13 @@ namespace NodesGenerator.XmlModel
[XmlAttribute]
public string Value;
public int CompareTo(HelpUnit other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
return string.Compare(Key, other.Key, StringComparison.Ordinal);
}
}
[Serializable]
@ -42,6 +49,7 @@ namespace NodesGenerator.XmlModel
helpElementKey as string,
(storage.HelpData[helpElementKey] as NodeGenerator.HelpContext).help_context));
}
HelpData.Sort();
}
public NodeGenerator.HelpStorage ToHelpStorage()

View file

@ -1,4 +1,6 @@
namespace NodesGenerator
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace NodesGenerator
{
partial class options_form
{

View file

@ -1,4 +1,6 @@
using System;
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

View file

@ -247,6 +247,11 @@ namespace VisualPascalABC
(new ICSharpCode.TextEditor.Actions.SelectWholeDocument()).Execute(TextEditor.ActiveTextAreaControl.TextArea);
}
public void DeselectAll()
{
(new ICSharpCode.TextEditor.Actions.ClearAllSelections()).Execute(TextEditor.ActiveTextAreaControl.TextArea);
}
public void Delete()
{
(new ICSharpCode.TextEditor.Actions.Delete()).Execute(TextEditor.ActiveTextAreaControl.TextArea);

View file

@ -645,7 +645,16 @@ namespace VisualPascalABC
get
{
string path = "";
if (UserOptions.UseOutputDirectory)
if (ProjectFactory.Instance.CurrentProject != null)
{
if (!string.IsNullOrEmpty(ProjectFactory.Instance.CurrentProject.OutputDirectory))
return Path.Combine(ProjectFactory.Instance.CurrentProject.OutputDirectory, ProjectFactory.Instance.CurrentProject.OutputFileName);
return Path.Combine(ProjectFactory.Instance.CurrentProject.ProjectDirectory, ProjectFactory.Instance.CurrentProject.OutputFileName);
}
if (UserOptions.UseOutputDirectory)
path = Path.Combine(UserOptions.OutputDirectory, Path.GetFileNameWithoutExtension(CurrentSourceFileName)) + ".exe";
else
path = Path.ChangeExtension(CurrentSourceFileName, ".exe");

View file

@ -567,6 +567,7 @@ namespace VisualPascalABC
public override void Execute(TextArea textArea)
{
WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList();
VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DeselectAll();
CodeFormatters.CodeFormatter cf = new CodeFormatters.CodeFormatter(VisualPABCSingleton.MainForm.UserOptions.TabIndent);
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
//PascalABCCompiler.SyntaxTree.syntax_tree_node sn =

View file

@ -13,7 +13,7 @@ namespace VisualPascalABC
{
public delegate void ParseInformationUpdatedDelegate(object obj, string fileName);
public class CodeCompletionParserController
public class CodeCompletionParserController : VisualPascalABCPlugins.ICodeCompletionService
{
public static Hashtable open_files = new Hashtable(StringComparer.OrdinalIgnoreCase);
public VisualEnvironmentCompiler visualEnvironmentCompiler;
@ -35,10 +35,8 @@ namespace VisualPascalABC
public CodeCompletionParserController()
{
//this.visualEnvironmentCompiler = visualEnvironmentCompiler;
this.th = new System.Threading.Thread(new System.Threading.ThreadStart(ParseInThread));
ccp = new CodeCompletionProvider();
//CodeCompletion.CodeCompletionController.OpenFiles = open_files;
}
public PascalABCCompiler.Parsers.ICodeCompletionDomConverter GetConverter(string fileName)

Some files were not shown because too many files have changed in this diff Show more