Merge remote-tracking branch 'remotes/origin/master'
# Conflicts: # Configuration/GlobalAssemblyInfo.cs # Configuration/Version.defs # ReleaseGenerators/PascalABCNET_version.nsh
This commit is contained in:
commit
113896662d
|
|
@ -350,13 +350,24 @@ namespace CodeFormatters
|
|||
if (multi_line_nodes.Count > 0)
|
||||
{
|
||||
if (multi_line_nodes.Count == 1)
|
||||
lines[i] = new string(' ', addit_pos_for_multiline) + lines[i];
|
||||
{
|
||||
if (!(multi_line_nodes.Peek() is function_lambda_definition))
|
||||
lines[i] = new string(' ', addit_pos_for_multiline) + lines[i];
|
||||
else
|
||||
lines[i] = new string(' ', off) + lines[i].Trim();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (off > lines[i].Length)
|
||||
lines[i] = new string(' ', addit_pos_for_multiline + off) + lines[i];
|
||||
if (!(multi_line_nodes.Peek() is function_lambda_definition))
|
||||
{
|
||||
if (off > lines[i].Length)
|
||||
lines[i] = new string(' ', addit_pos_for_multiline + off) + lines[i];
|
||||
else
|
||||
lines[i] = new string(' ', addit_pos_for_multiline) + lines[i];
|
||||
}
|
||||
else
|
||||
lines[i] = new string(' ', addit_pos_for_multiline) + lines[i];
|
||||
lines[i] = new string(' ', off) + lines[i].Trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -692,7 +703,8 @@ namespace CodeFormatters
|
|||
|| sn is lock_stmt || sn is loop_stmt || sn is simple_property || sn is read_accessor_name || sn is write_accessor_name
|
||||
|| sn is formal_parameters || sn is bracket_expr || sn is record_const || sn is array_const || sn is exception_handler
|
||||
|| sn is try_handler_finally || sn is try_handler_except || sn is external_directive || sn is where_definition
|
||||
|| (sn is simple_const_definition && in_class && !in_procedure) || (sn is typed_const_definition && in_class && !in_procedure))
|
||||
|| (sn is simple_const_definition && in_class && !in_procedure) || (sn is typed_const_definition && in_class && !in_procedure)
|
||||
)
|
||||
read_from_beg_pos = true;
|
||||
}
|
||||
sn.visit(this);
|
||||
|
|
|
|||
|
|
@ -719,6 +719,7 @@ namespace CodeCompletion
|
|||
_dot_node.left.visit(this);
|
||||
search_all = tmp2;
|
||||
by_dot = tmp;
|
||||
|
||||
if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcScope)
|
||||
{
|
||||
if (((returned_scope as ElementScope).sc as ProcScope).return_type != null)
|
||||
|
|
@ -728,6 +729,7 @@ namespace CodeCompletion
|
|||
}
|
||||
else if (returned_scope != null && returned_scope is ProcScope)
|
||||
{
|
||||
|
||||
ProcScope ps = returned_scope as ProcScope;
|
||||
if (ps.return_type == null)
|
||||
{
|
||||
|
|
@ -1030,6 +1032,8 @@ namespace CodeCompletion
|
|||
(_method_call.dereferencing_value as dot_node).left.visit(this);
|
||||
if (returned_scope is ElementScope)
|
||||
returned_scope = (returned_scope as ElementScope).sc;
|
||||
else if (returned_scope is ProcScope)
|
||||
returned_scope = (returned_scope as ProcScope).return_type;
|
||||
obj = returned_scope as TypeScope;
|
||||
by_dot = tmp;
|
||||
if (obj != null && proc.parameters != null && proc.parameters.Count > 0 && !(proc.parameters[0].sc is TemplateParameterScope || proc.parameters[0].sc is UnknownScope))
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ namespace CodeCompletion
|
|||
{
|
||||
if (with_body)
|
||||
{
|
||||
if (cur_scope != null && cur_scope.IsEqual(founded_scope))
|
||||
if (cur_scope != null && (cur_scope.IsEqual(founded_scope) || founded_scope is IProcScope && (founded_scope as IProcScope).Realization != null && cur_scope.IsEqual((founded_scope as IProcScope).Realization)))
|
||||
pos_list.Add(get_position(_procedure_header.name.meth_name));
|
||||
}
|
||||
else
|
||||
|
|
@ -447,6 +447,7 @@ namespace CodeCompletion
|
|||
if (_procedure_header.name.class_name != null)
|
||||
{
|
||||
sc = cur_scope.FindNameInAnyOrder(_procedure_header.name.class_name.name);
|
||||
|
||||
if (sc != null && sc.IsEqual(founded_scope))
|
||||
pos_list.Add(get_position(_procedure_header.name.class_name));
|
||||
}
|
||||
|
|
@ -469,7 +470,7 @@ namespace CodeCompletion
|
|||
{
|
||||
if (with_body)
|
||||
{
|
||||
if (cur_scope != null && cur_scope.IsEqual(founded_scope))
|
||||
if (cur_scope != null && (cur_scope.IsEqual(founded_scope) || founded_scope is IProcScope && (founded_scope as IProcScope).Realization != null && cur_scope.IsEqual((founded_scope as IProcScope).Realization)))
|
||||
pos_list.Add(get_position(_function_header.name.meth_name));
|
||||
}
|
||||
else
|
||||
|
|
@ -1573,6 +1574,42 @@ namespace CodeCompletion
|
|||
{
|
||||
_yield_node.ex.visit(this);
|
||||
}
|
||||
public override void visit(slice_expr _slice_expr)
|
||||
{
|
||||
_slice_expr.v.visit(this);
|
||||
if (_slice_expr.from != null)
|
||||
_slice_expr.from.visit(this);
|
||||
if (_slice_expr.to != null)
|
||||
_slice_expr.to.visit(this);
|
||||
if (_slice_expr.step != null)
|
||||
_slice_expr.step.visit(this);
|
||||
}
|
||||
public override void visit(slice_expr_question _slice_expr_question)
|
||||
{
|
||||
_slice_expr_question.v.visit(this);
|
||||
if (_slice_expr_question.from != null)
|
||||
_slice_expr_question.from.visit(this);
|
||||
if (_slice_expr_question.to != null)
|
||||
_slice_expr_question.to.visit(this);
|
||||
if (_slice_expr_question.step != null)
|
||||
_slice_expr_question.step.visit(this);
|
||||
}
|
||||
public override void visit(yield_sequence_node _yield_sequence_node)
|
||||
{
|
||||
_yield_sequence_node.ex.visit(this);
|
||||
}
|
||||
public override void visit(tuple_node _tuple_node)
|
||||
{
|
||||
_tuple_node.el.visit(this);
|
||||
}
|
||||
public override void visit(assign_var_tuple _assign_var_tuple)
|
||||
{
|
||||
for (int i = 0; i < _assign_var_tuple.idents.idents.Count; i++)
|
||||
{
|
||||
_assign_var_tuple.idents.idents[i].visit(this);
|
||||
}
|
||||
_assign_var_tuple.expr.visit(this);
|
||||
}
|
||||
public override void visit(modern_proc_type _modern_proc_type)
|
||||
{
|
||||
if (_modern_proc_type.aloneparam != null)
|
||||
|
|
|
|||
|
|
@ -2005,20 +2005,20 @@ namespace CodeCompletion
|
|||
int ind = this.template_parameters.IndexOf((parameter.sc as TypeScope).Name);
|
||||
ElementScope inst_param = null;
|
||||
if (gen_args.Count > ind && ind != -1)
|
||||
inst_param = new ElementScope(parameter.si, gen_args[ind], parameter.topScope);
|
||||
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), gen_args[ind], parameter.topScope);
|
||||
else
|
||||
inst_param = new ElementScope(parameter.si, parameter.sc, parameter.topScope);
|
||||
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), parameter.sc, parameter.topScope);
|
||||
instance.parameters.Add(inst_param);
|
||||
}
|
||||
else
|
||||
{
|
||||
ElementScope inst_param = null;
|
||||
if ((parameter.sc as TypeScope).IsGeneric)
|
||||
inst_param = new ElementScope(parameter.si, (parameter.sc as TypeScope).GetInstance(gen_args), parameter.topScope);
|
||||
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), (parameter.sc as TypeScope).GetInstance(gen_args), parameter.topScope);
|
||||
else if ((parameter.sc as TypeScope).GetElementType() != null && (parameter.sc as TypeScope).GetElementType().IsGenericParameter)
|
||||
inst_param = new ElementScope(parameter.si, (parameter.sc as TypeScope).GetInstance(gen_args), parameter.topScope);
|
||||
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), (parameter.sc as TypeScope).GetInstance(gen_args), parameter.topScope);
|
||||
else
|
||||
inst_param = new ElementScope(parameter.si, parameter.sc, parameter.topScope);
|
||||
inst_param = new ElementScope(new SymInfo(parameter.si.name, parameter.si.kind, parameter.si.description), parameter.sc, parameter.topScope);
|
||||
instance.parameters.Add(inst_param);
|
||||
}
|
||||
if (parameter.param_kind == parametr_kind.params_parametr && i < gen_args.Count)
|
||||
|
|
@ -5081,7 +5081,7 @@ namespace CodeCompletion
|
|||
}
|
||||
else
|
||||
{
|
||||
if (this.instances[i].instances != null && this.instances[i].instances.Count > 0 && gen_args[i].elementType != null)
|
||||
if (this.instances[i].instances != null && this.instances[i].instances.Count > 0 && i < gen_args.Count && gen_args[i].elementType != null)
|
||||
{
|
||||
List<TypeScope> lst = new List<TypeScope>();
|
||||
lst.Add(gen_args[i].elementType);
|
||||
|
|
@ -6763,10 +6763,16 @@ namespace CodeCompletion
|
|||
//private CompiledScope ret_type;
|
||||
|
||||
|
||||
public CompiledMethodScope(SymInfo si, MethodInfo mi, CompiledScope declaringType)
|
||||
public CompiledMethodScope(SymInfo si, MethodInfo mi, TypeScope declaringType)
|
||||
{
|
||||
this.si = si;
|
||||
this.mi = mi;
|
||||
if (declaringType == TypeTable.string_type && mi.GetParameters().Length >= 1 && mi.GetParameters()[0].ParameterType.Name == "IEnumerable`1")
|
||||
{
|
||||
List<TypeScope> type_list = new List<TypeScope>();
|
||||
type_list.Add(TypeTable.char_type);
|
||||
declaringType = TypeTable.get_compiled_type(mi.GetParameters()[0].ParameterType.GetGenericTypeDefinition()).GetInstance(type_list);
|
||||
}
|
||||
string[] args = declaringType.TemplateArguments;
|
||||
this.declaringType = declaringType;
|
||||
if (args != null)
|
||||
|
|
|
|||
|
|
@ -380,6 +380,11 @@ namespace CodeCompletion
|
|||
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw);
|
||||
assert(s.Trim('\n', ' ', '\t') == "Seq(0)\n.f1\n.Print");
|
||||
|
||||
test_str = "$'is {a}'";
|
||||
off = test_str.Length-2;
|
||||
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw);
|
||||
assert(s.Trim('\n', ' ', '\t') == "a");
|
||||
|
||||
int num_param = 0;
|
||||
//testirovanie nazhatija skobki
|
||||
test_str = "writeln";
|
||||
|
|
@ -835,7 +840,14 @@ namespace CodeCompletion
|
|||
CodeFormatters.CodeFormatter cf = new CodeFormatters.CodeFormatter(2);
|
||||
string Text2 = cf.FormatTree(Text, cu, 1, 1);
|
||||
if (Text != Text2)
|
||||
log.WriteLine("Inavlid formatting of File " + s);
|
||||
log.WriteLine("Invalid formatting of File " + s);
|
||||
string shouldFileName = Path.Combine(test_dir + @"\should",Path.GetFileName(s));
|
||||
if (File.Exists(shouldFileName))
|
||||
{
|
||||
string shouldText = new StreamReader(s, System.Text.Encoding.GetEncoding(1251)).ReadToEnd();
|
||||
if (Text != shouldText)
|
||||
log.WriteLine("Invalid formatting of File " + s);
|
||||
}
|
||||
}
|
||||
log.Close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "3";
|
||||
public const string Build = "5";
|
||||
public const string Revision = "1642";
|
||||
public const string Revision = "1660";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=3
|
||||
%REVISION%=1642
|
||||
%REVISION%=1660
|
||||
%COREVERSION%=5
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -126,19 +126,22 @@ namespace ICSharpCode.TextEditor.Document
|
|||
{
|
||||
int brackets = -1;
|
||||
// first try "quick find" - find the matching bracket if there is no string/comment in the way
|
||||
bool kavs = false;
|
||||
for (int i = offset; i >= 0; --i) {
|
||||
char ch = document.GetCharAt(i);
|
||||
if (ch == openBracket) {
|
||||
if (!kavs)
|
||||
++brackets;
|
||||
if (brackets == 0) return i;
|
||||
} else if (ch == closingBracket) {
|
||||
--brackets;
|
||||
if (!kavs)
|
||||
--brackets;
|
||||
}
|
||||
else if (ch == '"')
|
||||
{
|
||||
break;
|
||||
} else if (ch == '\'') {
|
||||
//break;
|
||||
kavs = !kavs;
|
||||
} else if (ch == '/' && i > 0) {
|
||||
if (document.GetCharAt(i - 1) == '/') break;
|
||||
if (document.GetCharAt(i - 1) == '*') break;
|
||||
|
|
@ -150,18 +153,21 @@ namespace ICSharpCode.TextEditor.Document
|
|||
public virtual int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)
|
||||
{
|
||||
int brackets = 1;
|
||||
bool kavs = false;
|
||||
// try "quick find" - find the matching bracket if there is no string/comment in the way
|
||||
for (int i = offset; i < document.TextLength; ++i) {
|
||||
char ch = document.GetCharAt(i);
|
||||
if (ch == openBracket) {
|
||||
++brackets;
|
||||
if (!kavs)
|
||||
++brackets;
|
||||
} else if (ch == closingBracket) {
|
||||
--brackets;
|
||||
if (!kavs)
|
||||
--brackets;
|
||||
if (brackets == 0) return i;
|
||||
} else if (ch == '"') {
|
||||
break;
|
||||
} else if (ch == '\'') {
|
||||
//break;
|
||||
kavs = !kavs;
|
||||
} else if (ch == '/' && i > 0) {
|
||||
if (document.GetCharAt(i - 1) == '/') break;
|
||||
} else if (ch == '*' && i > 0) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -157,6 +157,7 @@ namespace PascalABCCompiler.NETGenerator
|
|||
private int cur_line = 0;
|
||||
private ISymbolDocumentWriter new_doc;
|
||||
private List<LocalBuilder> pinned_variables = new List<LocalBuilder>();
|
||||
private bool pabc_rtl_converted = false;
|
||||
|
||||
private void CheckLocation(SemanticTree.ILocation Location)
|
||||
{
|
||||
|
|
@ -447,6 +448,7 @@ namespace PascalABCCompiler.NETGenerator
|
|||
|
||||
if (name == "PABCRtl" || name == "PABCRtl32")
|
||||
{
|
||||
pabc_rtl_converted = true;
|
||||
an.Flags = AssemblyNameFlags.PublicKey;
|
||||
an.VersionCompatibility = System.Configuration.Assemblies.AssemblyVersionCompatibility.SameProcess;
|
||||
an.HashAlgorithm = System.Configuration.Assemblies.AssemblyHashAlgorithm.None;
|
||||
|
|
@ -4599,7 +4601,7 @@ namespace PascalABCCompiler.NETGenerator
|
|||
switch (fal)
|
||||
{
|
||||
case field_access_level.fal_public: return MethodAttributes.Public;
|
||||
case field_access_level.fal_internal: return comp_opt.target == TargetType.Dll ? MethodAttributes.Public : MethodAttributes.Assembly;
|
||||
case field_access_level.fal_internal: return (comp_opt.target == TargetType.Dll && pabc_rtl_converted) ? MethodAttributes.Public : MethodAttributes.Assembly;
|
||||
case field_access_level.fal_protected: return MethodAttributes.FamORAssem;
|
||||
case field_access_level.fal_private: return MethodAttributes.Assembly;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1836,6 +1836,7 @@ namespace PascalABCCompiler.Parsers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
sb.Append(tt[i].Name);
|
||||
if (i < tt.Length - 1) sb.Append(',');
|
||||
|
|
@ -2151,22 +2152,26 @@ namespace PascalABCCompiler.Parsers
|
|||
if ((scope as IElementScope).Indexers.Length == 0)
|
||||
scope = (scope as IElementScope).Type;
|
||||
if (scope is IProcScope) scope = (scope as IProcScope).ReturnType;
|
||||
if (!(scope is IElementScope))
|
||||
{
|
||||
ITypeScope ts = scope as ITypeScope;
|
||||
if (ts == null) return null;
|
||||
if (tmp_si is ITypeScope) return null;
|
||||
ITypeScope[] indexers = ts.Indexers;
|
||||
if (indexers == null || indexers.Length == 0) return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("this");
|
||||
sb.Append('[');
|
||||
for (int i=0; i<indexers.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescriptionWithoutNamespace(indexers[i]));
|
||||
if (i < indexers.Length - 1)
|
||||
sb.Append(',');
|
||||
}
|
||||
if (!(scope is IElementScope))
|
||||
{
|
||||
ITypeScope ts = scope as ITypeScope;
|
||||
if (ts == null) return null;
|
||||
if (tmp_si is ITypeScope) return null;
|
||||
ITypeScope[] indexers = ts.Indexers;
|
||||
if ((indexers == null || indexers.Length == 0) && !(ts is IArrayScope))
|
||||
return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("this");
|
||||
sb.Append('[');
|
||||
if (indexers != null)
|
||||
for (int i = 0; i < indexers.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescriptionWithoutNamespace(indexers[i]));
|
||||
if (i < indexers.Length - 1)
|
||||
sb.Append(',');
|
||||
}
|
||||
else
|
||||
sb.Append("integer");
|
||||
sb.Append("] : ");
|
||||
sb.Append(GetSimpleDescriptionWithoutNamespace(ts.ElementType));
|
||||
return new string[1]{sb.ToString()};
|
||||
|
|
@ -2715,6 +2720,8 @@ namespace PascalABCCompiler.Parsers
|
|||
{
|
||||
if (kav.Count == 0)
|
||||
{
|
||||
if (keyw == KeywordKind.None)
|
||||
return sb.ToString();
|
||||
sb.Insert(0, ch);
|
||||
break;
|
||||
}
|
||||
|
|
@ -3075,16 +3082,26 @@ namespace PascalABCCompiler.Parsers
|
|||
j--;
|
||||
Stack<char> kav_stack = new Stack<char>();
|
||||
j++;
|
||||
bool in_format_str = false;
|
||||
while (j <= i)
|
||||
{
|
||||
if (Text[j] == '\'')
|
||||
{
|
||||
if (kav_stack.Count == 0 && !in_keyw)
|
||||
kav_stack.Push('\'');
|
||||
{
|
||||
if (j == 0 || Text[j - 1] != '$')
|
||||
kav_stack.Push('\'');
|
||||
else
|
||||
{
|
||||
in_keyw = false;
|
||||
in_format_str = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (kav_stack.Count > 0)
|
||||
kav_stack.Pop();
|
||||
}
|
||||
else if (Text[j] == '{' && kav_stack.Count == 0)
|
||||
else if (Text[j] == '{' && kav_stack.Count == 0 && !in_format_str)
|
||||
in_keyw = true;
|
||||
else
|
||||
if (Text[j] == '}')
|
||||
|
|
|
|||
|
|
@ -220,10 +220,16 @@ namespace PascalABCCompiler.PascalABCNewParser
|
|||
public override syntax_tree_node BuildTreeInExprMode(string FileName, string Text)
|
||||
{
|
||||
// LineCorrection = -1 не забыть
|
||||
string origText = Text;
|
||||
Text = String.Concat("<<expression>>", Environment.NewLine, Text);
|
||||
localparserhelper = new GPPGParserHelper(Errors, Warnings, FileName);
|
||||
// localparser.parsertools.LineCorrection = -1;
|
||||
syntax_tree_node root = localparserhelper.Parse(Text);
|
||||
if (root == null && origText != null && origText.Contains("<"))
|
||||
{
|
||||
Errors.Clear();
|
||||
root = localparserhelper.Parse(String.Concat("<<expression>>", Environment.NewLine, origText.Replace("<","&<")));
|
||||
}
|
||||
return root as expression;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.3.5.1642'
|
||||
!define VERSION '3.3.5.1660'
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ namespace SyntaxVisitors
|
|||
return;
|
||||
}
|
||||
|
||||
if (cd.body == null)
|
||||
return;
|
||||
var fields = cd.body.class_def_blocks.SelectMany(cm => cm.members.Where(decl => decl is var_def_statement)
|
||||
.Select(decl1 => (decl1 as var_def_statement).vars.idents)
|
||||
.SelectMany(ids => ids.Select(id => id)));
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ namespace SyntaxVisitors
|
|||
// Yoda
|
||||
return;
|
||||
}
|
||||
|
||||
if (cd.body == null)
|
||||
return;
|
||||
var methods = cd.body.class_def_blocks.SelectMany(cm => cm.members.Select(decl1 =>
|
||||
{
|
||||
if (decl1 is procedure_header)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ namespace SyntaxVisitors
|
|||
// Yoda
|
||||
return;
|
||||
}
|
||||
|
||||
if (cd.body == null)
|
||||
return;
|
||||
var properties = cd.body.class_def_blocks.SelectMany(cm => cm.members.Select(decl => decl as simple_property)
|
||||
.Where(name => (object)name != null)
|
||||
.Select(sp => sp.property_name));
|
||||
|
|
|
|||
18
TestSuite/CompilationSamples/Data.pas
Normal file
18
TestSuite/CompilationSamples/Data.pas
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
unit Data;
|
||||
|
||||
//обязательно params
|
||||
procedure p2(params o: array of Exception) := exit;//не обязательно короткая процедура
|
||||
|
||||
procedure p1 :=//не обязательно короткая процедура
|
||||
try
|
||||
if true then
|
||||
p2(nil);
|
||||
except
|
||||
//обязательно on do и использование переменной исключения в процедуре с params
|
||||
on e: Exception do
|
||||
|
||||
p2(e);
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
@ -34,8 +34,11 @@ type
|
|||
TupleInt3 = (integer, integer, integer);
|
||||
TupleReal3 = (real, real, real);
|
||||
Point3D = Point3D;
|
||||
Vector3D = Vector3D;
|
||||
Point = System.Windows.Point;
|
||||
Ray3D = HelixToolkit.Wpf.Ray3D;
|
||||
Line3D = class(Ray3D) end;
|
||||
Plane3D = HelixToolkit.Wpf.Plane3D;
|
||||
|
||||
var
|
||||
hvp: HelixViewport3D;
|
||||
|
|
@ -60,7 +63,11 @@ function Sz3D(x, y, z: real) := new Size3D(x, y, z);
|
|||
function Pnt(x, y: real) := new Point(x, y);
|
||||
function Rect(x, y, w, h: real) := new System.Windows.Rect(x, y, w, h);
|
||||
|
||||
function operator*(p: Point3D; r: real); extensionmethod := P3D(p.x*r,p.y*r,p.z*r);
|
||||
function operator*(p: Point3D; r: real): Point3D; extensionmethod := p.Multiply(r);
|
||||
|
||||
function operator*(r: real; p: Point3D): Point3D; extensionmethod := p.Multiply(r);
|
||||
|
||||
function operator+(p1,p2: Point3D): Point3D; extensionmethod := p3d(p1.X+p2.X,p1.Y+p2.Y,p1.Z+p2.Z);
|
||||
|
||||
const
|
||||
OrtX = V3D(1, 0, 0);
|
||||
|
|
@ -211,7 +218,13 @@ type
|
|||
CameraType = class
|
||||
private
|
||||
function Cam: GCamera := hvp.Camera;
|
||||
procedure SetPP(p: Point3D) := begin Cam.Position := p;Cam.LookDirection := Cam.Position.Multiply(-1).ToVector3D; end;
|
||||
procedure SetPP(p: Point3D);
|
||||
begin
|
||||
Cam.Position := p;
|
||||
{if p<>(0,0,0) then
|
||||
Cam.LookDirection := Cam.Position.Multiply(-1).ToVector3D
|
||||
else Cam.LookDirection := V3D(1,0,0);}
|
||||
end;
|
||||
procedure SetP(p: Point3D) := Invoke(SetPP, p);
|
||||
function GetP: Point3D := Invoke&<Point3D>(()->Cam.Position);
|
||||
procedure SetLDP(v: Vector3D) := Cam.LookDirection := v;
|
||||
|
|
@ -1045,7 +1058,6 @@ type
|
|||
end;
|
||||
|
||||
da := AddDoubleAnimByName(sb, angle, seconds, ttname, AxisAngleRotation3D.AngleProperty, wait);
|
||||
var (d1,d2) := (da.BeginTime,da.Duration);
|
||||
end;
|
||||
|
||||
public
|
||||
|
|
@ -2019,7 +2031,7 @@ type
|
|||
constructor(x, y, z, Length: real; m: GMaterial) := CreateBase(new OctahedronVisual3D(Length), x, y, z, m);
|
||||
function Clone := (inherited Clone) as OctahedronT;
|
||||
end;
|
||||
|
||||
|
||||
PrismVisual3D = class(MeshElement3D)
|
||||
private
|
||||
fn: integer;
|
||||
|
|
@ -2071,6 +2083,74 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
TriangleVisual3D = class(MeshElement3D)
|
||||
private
|
||||
pp1,pp2,pp3: Point3D;
|
||||
protected
|
||||
function Tessellate(): MeshGeometry3D; override;
|
||||
begin
|
||||
var m := new MeshBuilder(true);
|
||||
m.AddTriangle(p1,p2,p3);
|
||||
Result := m.ToMesh;
|
||||
end;
|
||||
procedure SetP1(p1: Point3D);
|
||||
begin
|
||||
pp1 := p1;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
procedure SetP2(p1: Point3D);
|
||||
begin
|
||||
pp2 := p2;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
procedure SetP3(p3: Point3D);
|
||||
begin
|
||||
pp3 := p3;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
public
|
||||
constructor(ppp1,ppp2,ppp3: Point3D);
|
||||
begin
|
||||
(pp1, pp2, pp3) := (ppp1,ppp2,ppp3);
|
||||
Material := Colors.Red;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
property P1: Point3D read pp1 write SetP1;
|
||||
property P2: Point3D read pp2 write SetP2;
|
||||
property P3: Point3D read pp3 write SetP3;
|
||||
procedure SetPoints(p1,p2,p3: Point3D);
|
||||
begin
|
||||
pp1 := p1;
|
||||
pp2 := p2;
|
||||
pp3 := p3;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
TriangleT = class(ObjectWithMaterial3D)
|
||||
protected
|
||||
function Model := inherited model as TriangleVisual3D;
|
||||
procedure SetP1(p: Point3D) := Invoke(procedure(p: Point3D)->model.P1 := p, p);
|
||||
function GetP1: Point3D := Invoke&<Point3D>(()->model.P1);
|
||||
procedure SetP2(p: Point3D) := Invoke(procedure(p: Point3D)->model.P2 := p, p);
|
||||
function GetP2: Point3D := Invoke&<Point3D>(()->model.P2);
|
||||
procedure SetP3(p: Point3D) := Invoke(procedure(p: Point3D)->model.P3 := p, p);
|
||||
function GetP3: Point3D := Invoke&<Point3D>(()->model.P3);
|
||||
|
||||
function CreateObject: Object3D; override := new TriangleT(Model.p1, Model.p2, Model.p3, Material.Clone);
|
||||
public
|
||||
constructor(p1,p2,p3: Point3D; m: Gmaterial);
|
||||
begin
|
||||
CreateBase(new TriangleVisual3D(p1,p2,p3), 0, 0, 0, m);
|
||||
Model.BackMaterial := Model.Material;
|
||||
end;
|
||||
property P1: Point3D read GetP1 write SetP1;
|
||||
property P2: Point3D read GetP2 write SetP2;
|
||||
property P3: Point3D read GetP3 write SetP3;
|
||||
procedure SetPoints(p1,p2,p3: Point3D) := Invoke(procedure(p1,p2,p3: Point3D)->begin model.SetPoints(p1,p2,p3); end, p1,p2,p3);
|
||||
end;
|
||||
|
||||
|
||||
PrismT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
function Model := inherited model as PrismVisual3D;
|
||||
|
|
@ -2364,7 +2444,7 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
function FindObject3D(x,y: real): Object3D;
|
||||
function FindNearestObject(x,y: real): Object3D;
|
||||
begin
|
||||
Result := nil;
|
||||
var v := hvp.FindNearestVisual(new Point(x,y));
|
||||
|
|
@ -2373,24 +2453,52 @@ begin
|
|||
Result := obj
|
||||
end;
|
||||
|
||||
function FindNearestPoint(x,y: real; var p: Point3D): boolean;
|
||||
var BadPoint := P3D(real.MaxValue,real.MaxValue,real.MaxValue);
|
||||
|
||||
function FindNearestObjectPoint(x,y: real): Point3D;
|
||||
begin
|
||||
var p1 := hvp.FindNearestPoint(Pnt(x,y));
|
||||
Result := p1.HasValue;
|
||||
if p1.HasValue then
|
||||
p := p1.Value
|
||||
else p := P3D(0,0,0);
|
||||
Result := p1.Value
|
||||
else Result := BadPoint;
|
||||
end;
|
||||
|
||||
function Plane(p: Point3D; normal: Vector3D): Plane3D := new Plane3D(p,normal);
|
||||
function Ray(p: Point3D; v: Vector3D): Ray3D := new Ray3D(p,v);
|
||||
function Line(p: Point3D; v: Vector3D): Line3D := new Line3D(p,v);
|
||||
function Line(p1,p2: Point3D): Line3D := new Line3D(p1,p2-p1);
|
||||
|
||||
var
|
||||
PlaneXY := Plane(Origin,OrtZ);
|
||||
PlaneYZ := Plane(Origin,OrtX);
|
||||
PlaneXZ := Plane(Origin,OrtY);
|
||||
XAxis := Ray(Origin,OrtX);
|
||||
YAxis := Ray(Origin,OrtY);
|
||||
ZAxis := Ray(Origin,OrtZ);
|
||||
|
||||
function GetRay(x,y: real): Ray3D := hvp.Viewport.GetRay(Pnt(x,y));
|
||||
|
||||
function PlaneIntersection(x,y: real; p: Point3D; v: Vector3D; var pr: Point3D): boolean;
|
||||
function PointOnPlane(Self: Plane3D; x,y: real): Point3D; extensionmethod;
|
||||
begin
|
||||
var p1 := GetRay(x,y).PlaneIntersection(p,v);
|
||||
Result := p1.HasValue;
|
||||
var r := GetRay(x,y);
|
||||
//Println(r);
|
||||
var p1 := r.PlaneIntersection(Self.Position,Self.Normal);
|
||||
if p1.HasValue then
|
||||
pr := p1.Value
|
||||
else pr := P3D(0,0,0);
|
||||
Result := p1.Value
|
||||
else Result := BadPoint;
|
||||
end;
|
||||
|
||||
function NearestPointOnLine(Self: Ray3D; x,y: real): Point3D; extensionmethod;
|
||||
begin
|
||||
var ray := GetRay(x,y);
|
||||
var a := Self.Direction;
|
||||
var b := ray.Direction;
|
||||
var ab := Vector3D.CrossProduct(a,b);
|
||||
var planeNormal := Vector3D.CrossProduct(b,ab);
|
||||
var p := Self.PlaneIntersection(ray.Origin,planeNormal);
|
||||
if p.HasValue then
|
||||
Result := p.Value
|
||||
else Result := BadPoint;
|
||||
end;
|
||||
|
||||
function DefaultMaterialColor := RandomColor;
|
||||
|
|
@ -2504,11 +2612,14 @@ function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColo
|
|||
function Torus(x, y, z, Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Inv(()->TorusT.Create(x,y,z,Diameter, TubeDiameter, m));
|
||||
function Torus(p: Point3D; Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDiameter,m);
|
||||
|
||||
function Triangle(p1,p2,p3: Point3D; m: Material := DefaultMaterial): TriangleT := Inv(()->TriangleT.Create(p1,p2,p3, m));
|
||||
|
||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
function MyH(x, y, z, Length: real; c: Material): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
|
||||
function Any(x, y, z: real; c: Color): AnyT := Inv(()->AnyT.Create(x, y, z, c));
|
||||
|
||||
|
||||
procedure ProbaP;
|
||||
begin
|
||||
//var m := MaterialHelper.CreateMaterial(Brushes.Green,100,100);
|
||||
|
|
|
|||
16
TestSuite/errors/err0236.pas
Normal file
16
TestSuite/errors/err0236.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
type
|
||||
//обязательно предописание
|
||||
t1 = class;
|
||||
|
||||
t1 = abstract class
|
||||
|
||||
public
|
||||
procedure p1; abstract;
|
||||
|
||||
function f1: byte; abstract;
|
||||
|
||||
end;
|
||||
|
||||
function t1.f1: byte := f1;
|
||||
|
||||
begin end.
|
||||
8
TestSuite/formatter_tests/input/Program1114.pas
Normal file
8
TestSuite/formatter_tests/input/Program1114.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
begin
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
end)).Start;
|
||||
end.
|
||||
14
TestSuite/formatter_tests/input/Program1115.pas
Normal file
14
TestSuite/formatter_tests/input/Program1115.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
begin
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
end)).Start;
|
||||
end)).Start;
|
||||
end.
|
||||
22
TestSuite/formatter_tests/input/lambdas_closures_10.pas
Normal file
22
TestSuite/formatter_tests/input/lambdas_closures_10.pas
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
type
|
||||
Recurrent<T> = class
|
||||
first: T;
|
||||
next: Func<T,T>;
|
||||
count: integer;
|
||||
constructor (f: T; n: Func<T,T>; c: integer);
|
||||
begin
|
||||
first := f;
|
||||
next := n;
|
||||
count := c;
|
||||
end;
|
||||
|
||||
function f(): IEnumerable<T>;
|
||||
begin
|
||||
result := Range(1, count).Select(x -> begin result := first; first := next(first); end)
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var a := new Recurrent<integer>(1, x -> x * 2, 10);
|
||||
writeln(a.f());
|
||||
end.
|
||||
18
TestSuite/formatter_tests/input/lambdas_closures_11.pas
Normal file
18
TestSuite/formatter_tests/input/lambdas_closures_11.pas
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
var a: integer;
|
||||
type
|
||||
t1 = class
|
||||
|
||||
public constructor(i: integer);
|
||||
begin
|
||||
var p:procedure := () ->begin
|
||||
a := i;
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var t := new t1(2);
|
||||
assert(a = 2);
|
||||
end.
|
||||
24
TestSuite/formatter_tests/input/lambdas_closures_12.pas
Normal file
24
TestSuite/formatter_tests/input/lambdas_closures_12.pas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
var i: integer;
|
||||
type
|
||||
t2 = class
|
||||
procedure Redraw;
|
||||
begin
|
||||
i := 1;
|
||||
end;
|
||||
|
||||
constructor(Redraw: boolean);
|
||||
begin
|
||||
var p:procedure := ()->
|
||||
begin
|
||||
if Redraw then
|
||||
self.Redraw;
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
new t2(true);
|
||||
assert(i = 1);
|
||||
end.
|
||||
25
TestSuite/formatter_tests/input/lambdas_closures_13.pas
Normal file
25
TestSuite/formatter_tests/input/lambdas_closures_13.pas
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
type
|
||||
t1 = class
|
||||
|
||||
public class i: integer;
|
||||
|
||||
procedure p1;
|
||||
begin
|
||||
var i2: integer;
|
||||
|
||||
var p: procedure := ()->begin
|
||||
|
||||
i += 1;
|
||||
i2 += 1;
|
||||
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var o := new t1;
|
||||
o.p1;
|
||||
assert(t1.i = 1);
|
||||
end.
|
||||
5
TestSuite/formatter_tests/input/lambdas_closures_8.pas
Normal file
5
TestSuite/formatter_tests/input/lambdas_closures_8.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
begin
|
||||
var f: IntFunc := x->x*4;
|
||||
var g: IntFunc := x->x + f(0);
|
||||
f(1);
|
||||
end.
|
||||
7
TestSuite/formatter_tests/input/lambdas_closures_9.pas
Normal file
7
TestSuite/formatter_tests/input/lambdas_closures_9.pas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin
|
||||
var x: integer := 5;
|
||||
var a: array of integer := (x,x,x);
|
||||
var f: IntFunc := y->y+a[0]+x;
|
||||
writeln(f(1));
|
||||
writeln(a[2]);
|
||||
end.
|
||||
8
TestSuite/formatter_tests/should/Program1114.pas
Normal file
8
TestSuite/formatter_tests/should/Program1114.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
begin
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
end)).Start;
|
||||
end.
|
||||
14
TestSuite/formatter_tests/should/Program1115.pas
Normal file
14
TestSuite/formatter_tests/should/Program1115.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
begin
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
(new System.Threading.Thread(()->begin
|
||||
//комментарий
|
||||
writeln;//
|
||||
writeln;
|
||||
//не_код
|
||||
end)).Start;
|
||||
end)).Start;
|
||||
end.
|
||||
25
TestSuite/formatter_tests/should/lambdas_closures_13.pas
Normal file
25
TestSuite/formatter_tests/should/lambdas_closures_13.pas
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
type
|
||||
t1 = class
|
||||
|
||||
public class i: integer;
|
||||
|
||||
procedure p1;
|
||||
begin
|
||||
var i2: integer;
|
||||
|
||||
var p: procedure := ()->begin
|
||||
|
||||
i += 1;
|
||||
i2 += 1;
|
||||
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var o := new t1;
|
||||
o.p1;
|
||||
assert(t1.i = 1);
|
||||
end.
|
||||
10
TestSuite/generics18.pas
Normal file
10
TestSuite/generics18.pas
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function f1 := 1;
|
||||
function f2 := 2;
|
||||
begin
|
||||
var a := Arr&<function: integer>(f1, f2);
|
||||
var a2 := Arr&<function: integer>(f1, f2);
|
||||
assert(a[0] = 1);
|
||||
assert(a[1]() = 2);
|
||||
assert(a2[0] = 1);
|
||||
assert(a2[1]() = 2);
|
||||
end.
|
||||
7
TestSuite/intellisense_tests/extensionmethods7.pas
Normal file
7
TestSuite/intellisense_tests/extensionmethods7.pas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function f1<T>(self:sequence of T); extensionmethod := self;
|
||||
|
||||
begin
|
||||
Seq(0)
|
||||
.f1&<integer>.Distinct{@(расширение sequence of T) function Distinct<integer>(): sequence of integer;@};
|
||||
;
|
||||
end.
|
||||
11
TestSuite/intellisense_tests/generics5.pas
Normal file
11
TestSuite/intellisense_tests/generics5.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function f1<T>(self: sequence of T): (sequence of byte, sequence of word);
|
||||
begin
|
||||
Result := (
|
||||
Seq(byte(0)),
|
||||
Seq(word(0))
|
||||
);
|
||||
end;
|
||||
|
||||
begin
|
||||
var a{@var a: (IEnumerable<byte>,IEnumerable<word>);@} := f1(Seq(0));
|
||||
end.
|
||||
11
TestSuite/intellisense_tests/generics6.pas
Normal file
11
TestSuite/intellisense_tests/generics6.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
type
|
||||
t1<T> = class
|
||||
|
||||
public
|
||||
procedure p1; virtual;
|
||||
|
||||
end;
|
||||
|
||||
procedure t1<T>.p1{@procedure t1<>.p1(); virtual;@} := p1;
|
||||
|
||||
begin end.
|
||||
3
TestSuite/intellisense_tests/generics7.pas
Normal file
3
TestSuite/intellisense_tests/generics7.pas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin
|
||||
''.Select{@(расширение sequence of T) function Select<char,TResult>(selector: char->TResult): sequence of TResult;@}(x->Ord(x));
|
||||
end.
|
||||
16
TestSuite/yield4.pas
Normal file
16
TestSuite/yield4.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
type
|
||||
t1 = class;
|
||||
|
||||
t1 = class
|
||||
function f1: sequence of byte;
|
||||
begin
|
||||
yield 0;//обязательно yield
|
||||
yield 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
var o1:t1 := new t1;
|
||||
var arr := o1.f1.ToArray;
|
||||
assert(arr[1] = 1);
|
||||
end.
|
||||
|
|
@ -796,7 +796,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
int i = 0;
|
||||
if (si.sym_info == null)
|
||||
AddError(new ExpectedType(loc));
|
||||
{
|
||||
if (name.ToLower() == "result")
|
||||
AddError(loc, "CAN_NOT_DEDUCE_TYPE_{0}", "Result");
|
||||
else
|
||||
AddError(new ExpectedType(loc));
|
||||
}
|
||||
|
||||
if (si.sym_info.semantic_node_type == semantic_node_type.wrap_def)
|
||||
{
|
||||
BasePCUReader.RestoreSymbol(si, name);
|
||||
|
|
|
|||
|
|
@ -903,7 +903,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
vdn = syntax_tree_visitor.context.add_field(get_temp_arr_name(), loc, pr.type, polymorphic_state.ps_static);
|
||||
else
|
||||
vdn = syntax_tree_visitor.context.add_var_definition_in_entry_scope(get_temp_arr_name(), loc);
|
||||
|
||||
}
|
||||
else if (syntax_tree_visitor.context.converted_type != null)
|
||||
vdn = syntax_tree_visitor.context.add_field(get_temp_arr_name(), loc, pr.type, polymorphic_state.ps_static);
|
||||
|
|
|
|||
|
|
@ -1206,14 +1206,14 @@ namespace PascalABCCompiler.TreeConverter
|
|||
bfc = ((right as typed_expression).type as delegated_methods).proper_methods[0];
|
||||
right = convertion_data_and_alghoritms.explicit_convert_type(right, CreateDelegate(bfc.simple_function_node));
|
||||
sil2 = right.type.find_in_type(name);
|
||||
if (saved_sil != null)
|
||||
if (saved_sil != null && sil != null)
|
||||
{
|
||||
sil.RemoveRange(1, sil.Count() - 1);
|
||||
sil.AddRange(saved_sil);
|
||||
}
|
||||
else
|
||||
saved_sil = sil;
|
||||
if (saved_sil2 != null)
|
||||
if (saved_sil2 != null && sil2 != null)
|
||||
{
|
||||
sil2.RemoveRange(1, sil2.Count() - 1);
|
||||
sil2.AddRange(saved_sil2);
|
||||
|
|
@ -1798,6 +1798,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
statement_node stm = convert_strong(eh.statements);
|
||||
context.leave_code_block();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
sl.statements.AddElement(stm);
|
||||
stm = sl;
|
||||
}
|
||||
|
||||
exception_filter ef = new exception_filter(filter_type, lvr, stm, get_location(eh));
|
||||
efl.AddElement(ef);
|
||||
current_catch_excep = null;
|
||||
|
|
@ -9561,7 +9567,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (string.Compare(cl_def.template_args.idents[i].name, ttn.template_args.idents[i].name, true) != 0)
|
||||
{
|
||||
AddError(get_location(ttn.template_args.idents[i]), "PARAMETER_{0}_MUST_BE_NAMED_{1}", cl_def.template_args.idents[i].name, i + 1);
|
||||
AddError(get_location(ttn.template_args.idents[i]), "PARAMETER_{0}_MUST_BE_NAMED_{1}", i + 1, cl_def.template_args.idents[i].name);
|
||||
}
|
||||
}
|
||||
_method_name.class_name = new SyntaxTree.ident(ttn.name);
|
||||
|
|
@ -9583,7 +9589,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (string.Compare(tp.generic_params[i].name, ttn.template_args.idents[i].name, true) != 0)
|
||||
{
|
||||
AddError(get_location(ttn.template_args.idents[i]), "PARAMETER_{0}_MUST_BE_NAMED_{1}", tp.generic_params[i].name, i+1);
|
||||
AddError(get_location(ttn.template_args.idents[i]), "PARAMETER_{0}_MUST_BE_NAMED_{1}", i + 1, tp.generic_params[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12618,6 +12624,14 @@ namespace PascalABCCompiler.TreeConverter
|
|||
common_method_node cmnode = context.top_function as common_method_node;
|
||||
context.set_virtual_abstract(cmnode);
|
||||
}
|
||||
if (context.converted_type != null)
|
||||
{
|
||||
common_method_node cmnode = context.top_function as common_method_node;
|
||||
if (cmnode != null && cmnode.polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract && body_exists)
|
||||
{
|
||||
AddError(new AbstractMethodWithBody(get_location(_function_header)));
|
||||
}
|
||||
}
|
||||
convertion_data_and_alghoritms.create_function_return_variable(context.top_function, si);
|
||||
|
||||
if (!body_exists)
|
||||
|
|
@ -16817,16 +16831,27 @@ namespace PascalABCCompiler.TreeConverter
|
|||
return_value(new question_colon_expression(condition, left, right, get_location(node)));
|
||||
}
|
||||
|
||||
Dictionary<SyntaxTree.type_definition, type_node> delegate_cache = new Dictionary<type_definition, type_node>();
|
||||
|
||||
public List<type_node> visit_type_list(List<SyntaxTree.type_definition> types)
|
||||
{
|
||||
List<type_node> tparams = new List<type_node>();
|
||||
foreach (SyntaxTree.type_definition id in types)
|
||||
{
|
||||
type_node tn = convert_strong(id);
|
||||
type_node tn = null;
|
||||
if ((id is function_header || id is procedure_header) && delegate_cache.ContainsKey(id))
|
||||
tn = delegate_cache[id];
|
||||
else
|
||||
tn = convert_strong(id);
|
||||
|
||||
if (tn == null)
|
||||
{
|
||||
AddError(get_location(id), "TYPE_NAME_EXPECTED");
|
||||
}
|
||||
if ((id is function_header || id is procedure_header) && !delegate_cache.ContainsKey(id))
|
||||
{
|
||||
delegate_cache[id] = tn;
|
||||
}
|
||||
tparams.Add(tn);
|
||||
}
|
||||
return tparams;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ namespace ICSharpCode.TextEditor.Util
|
|||
availableArea.Height = Math.Max
|
||||
(0, availableArea.Height - pixelsUsed);
|
||||
|
||||
otherDim = Math.Max(otherDim, requiredArea.Width);
|
||||
otherDim = Math.Max(otherDim, requiredArea.Width+8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ namespace ICSharpCode.TextEditor.Util
|
|||
tipSize = Graphics.MeasureString
|
||||
((param_desc?" ":" ")+tipText, tipFont, MaximumSize,
|
||||
GetInternalStringFormat());
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
tipSize = Graphics.MeasureString
|
||||
|
|
|
|||
|
|
@ -257,13 +257,6 @@ namespace VisualPascalABC
|
|||
}
|
||||
PascalABCCompiler.Parsers.Position p = fnd_scope.GetPosition();
|
||||
bool need_add_def = !for_refact; // true
|
||||
//if (for_refact)
|
||||
//foreach (PascalABCCompiler.Parsers.Position pos in lst)
|
||||
// if (p.file_name == pos.file_name && p.line == pos.line && p.column == pos.column && p.end_line == pos.end_line && p.end_column == pos.end_column)
|
||||
// {
|
||||
// need_add_def = false;
|
||||
// break;
|
||||
// }
|
||||
if (p.file_name != null && need_add_def)
|
||||
svs_lst.Add(new SymbolsViewerSymbol(new PascalABCCompiler.SourceLocation(p.file_name, p.line, p.column, p.end_line, p.end_column), ImagesProvider.GetPictureNum(fnd_scope.SymbolInfo)));
|
||||
foreach (PascalABCCompiler.Parsers.Position pos in lst)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ function Sz3D(x, y, z: real) := new Size3D(x, y, z);
|
|||
function Pnt(x, y: real) := new Point(x, y);
|
||||
function Rect(x, y, w, h: real) := new System.Windows.Rect(x, y, w, h);
|
||||
|
||||
function operator*(p: Point3D; r: real); extensionmethod := P3D(p.x*r,p.y*r,p.z*r);
|
||||
function operator*(p: Point3D; r: real): Point3D; extensionmethod := p.Multiply(r);
|
||||
|
||||
function operator*(r: real; p: Point3D): Point3D; extensionmethod := p.Multiply(r);
|
||||
|
||||
function operator+(p1,p2: Point3D): Point3D; extensionmethod := p3d(p1.X+p2.X,p1.Y+p2.Y,p1.Z+p2.Z);
|
||||
|
||||
const
|
||||
OrtX = V3D(1, 0, 0);
|
||||
|
|
@ -214,7 +218,13 @@ type
|
|||
CameraType = class
|
||||
private
|
||||
function Cam: GCamera := hvp.Camera;
|
||||
procedure SetPP(p: Point3D) := begin Cam.Position := p;Cam.LookDirection := Cam.Position.Multiply(-1).ToVector3D; end;
|
||||
procedure SetPP(p: Point3D);
|
||||
begin
|
||||
Cam.Position := p;
|
||||
{if p<>(0,0,0) then
|
||||
Cam.LookDirection := Cam.Position.Multiply(-1).ToVector3D
|
||||
else Cam.LookDirection := V3D(1,0,0);}
|
||||
end;
|
||||
procedure SetP(p: Point3D) := Invoke(SetPP, p);
|
||||
function GetP: Point3D := Invoke&<Point3D>(()->Cam.Position);
|
||||
procedure SetLDP(v: Vector3D) := Cam.LookDirection := v;
|
||||
|
|
@ -2022,25 +2032,6 @@ type
|
|||
function Clone := (inherited Clone) as OctahedronT;
|
||||
end;
|
||||
|
||||
TriangleVisual3D = class(MeshElement3D)
|
||||
private
|
||||
p1,p2,p3: Point3D;
|
||||
public
|
||||
constructor(pp1,pp2,pp3: Point3D);
|
||||
begin
|
||||
(p1, p2, p3) := (pp1,pp2,pp3);
|
||||
Material := Colors.Red;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
function Tessellate(): MeshGeometry3D; override;
|
||||
begin
|
||||
var pmb := new PanelModelBuilder();
|
||||
pmb.AddPanel(p1.X, p1.Y, p1.Z, p2.X, p2.Y, p2.Z, p3.X, p3.Y, p3.Z, p1.X, p1.Y, p1.Z);
|
||||
Result := pmb.ToMeshGeometry3D
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
PrismVisual3D = class(MeshElement3D)
|
||||
private
|
||||
fn: integer;
|
||||
|
|
@ -2092,6 +2083,74 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
TriangleVisual3D = class(MeshElement3D)
|
||||
private
|
||||
pp1,pp2,pp3: Point3D;
|
||||
protected
|
||||
function Tessellate(): MeshGeometry3D; override;
|
||||
begin
|
||||
var m := new MeshBuilder(true);
|
||||
m.AddTriangle(p1,p2,p3);
|
||||
Result := m.ToMesh;
|
||||
end;
|
||||
procedure SetP1(p1: Point3D);
|
||||
begin
|
||||
pp1 := p1;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
procedure SetP2(p1: Point3D);
|
||||
begin
|
||||
pp2 := p2;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
procedure SetP3(p3: Point3D);
|
||||
begin
|
||||
pp3 := p3;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
public
|
||||
constructor(ppp1,ppp2,ppp3: Point3D);
|
||||
begin
|
||||
(pp1, pp2, pp3) := (ppp1,ppp2,ppp3);
|
||||
Material := Colors.Red;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
property P1: Point3D read pp1 write SetP1;
|
||||
property P2: Point3D read pp2 write SetP2;
|
||||
property P3: Point3D read pp3 write SetP3;
|
||||
procedure SetPoints(p1,p2,p3: Point3D);
|
||||
begin
|
||||
pp1 := p1;
|
||||
pp2 := p2;
|
||||
pp3 := p3;
|
||||
OnGeometryChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
TriangleT = class(ObjectWithMaterial3D)
|
||||
protected
|
||||
function Model := inherited model as TriangleVisual3D;
|
||||
procedure SetP1(p: Point3D) := Invoke(procedure(p: Point3D)->model.P1 := p, p);
|
||||
function GetP1: Point3D := Invoke&<Point3D>(()->model.P1);
|
||||
procedure SetP2(p: Point3D) := Invoke(procedure(p: Point3D)->model.P2 := p, p);
|
||||
function GetP2: Point3D := Invoke&<Point3D>(()->model.P2);
|
||||
procedure SetP3(p: Point3D) := Invoke(procedure(p: Point3D)->model.P3 := p, p);
|
||||
function GetP3: Point3D := Invoke&<Point3D>(()->model.P3);
|
||||
|
||||
function CreateObject: Object3D; override := new TriangleT(Model.p1, Model.p2, Model.p3, Material.Clone);
|
||||
public
|
||||
constructor(p1,p2,p3: Point3D; m: Gmaterial);
|
||||
begin
|
||||
CreateBase(new TriangleVisual3D(p1,p2,p3), 0, 0, 0, m);
|
||||
Model.BackMaterial := Model.Material;
|
||||
end;
|
||||
property P1: Point3D read GetP1 write SetP1;
|
||||
property P2: Point3D read GetP2 write SetP2;
|
||||
property P3: Point3D read GetP3 write SetP3;
|
||||
procedure SetPoints(p1,p2,p3: Point3D) := Invoke(procedure(p1,p2,p3: Point3D)->begin model.SetPoints(p1,p2,p3); end, p1,p2,p3);
|
||||
end;
|
||||
|
||||
|
||||
PrismT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
function Model := inherited model as PrismVisual3D;
|
||||
|
|
@ -2553,7 +2612,7 @@ function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColo
|
|||
function Torus(x, y, z, Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Inv(()->TorusT.Create(x,y,z,Diameter, TubeDiameter, m));
|
||||
function Torus(p: Point3D; Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDiameter,m);
|
||||
|
||||
function Triangle(p1,p2,p3: Point3D): TriangleVisual3D := Inv(()->TriangleVisual3D.Create(p1,p2,p3));
|
||||
function Triangle(p1,p2,p3: Point3D; m: Material := DefaultMaterial): TriangleT := Inv(()->TriangleT.Create(p1,p2,p3, m));
|
||||
|
||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
function MyH(x, y, z, Length: real; c: Material): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
|
|
|
|||
Loading…
Reference in a new issue