Skip to content

Commit

Permalink
Merge branch 'pascalabcnet:master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
spectatorBH authored Jan 5, 2024
2 parents 29dc93f + 9b3cc5c commit 80a757b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions TestSuite/IsConsoleApp.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
begin
assert(IsConsoleApplication);
end.
4 changes: 4 additions & 0 deletions TestSuite/errors/err0532.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//!Операции нельзя вызывать, используя данный синтаксис
begin
Writeln(string.operator*=);
end.
2 changes: 2 additions & 0 deletions TreeConverter/TreeConversion/syntax_tree_visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9601,6 +9601,8 @@ private expression_node create_static_expression(type_node tn, SyntaxTree.ident

private void dot_node_as_type_ident(type_node tn, SyntaxTree.ident id_right, motivation mot)
{
if (id_right is SyntaxTree.operator_name_ident)
AddError(get_location(id_right), "OPERATIONS_CANNOT_BE_CALLED_USING_THIS_SYNTAX");
List<SymbolInfo> si_right = tn.find_in_type(id_right.name, context.CurrentScope);
if (si_right == null)
{
Expand Down
26 changes: 26 additions & 0 deletions TreeConverter/TreeRealization/programs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ public bool internal_dll
}
}

static HashSet<string> graph_modules = new HashSet<string>(new string[] { "GraphABC", "GraphWPF", "Graph3D", "PlotWPF", "Robot", "RobotField", "RobotZadan",
"RobotTaskMaker", "Drawman", "DrawManField", "ABCObjects", "ABCButtons", "ABCHouse", "ABCSprites",
"WPFObjects", "TurtleWPF", "Turtle", "Мозаика", "МозаикаABC", "FormsABC", "Чертежник", "Робот"});

public void create_main_function(string[] used_stand_modules, Dictionary<string, object> config)
{
add_needed_cctors();
Expand Down Expand Up @@ -313,6 +317,28 @@ public void create_main_function(string[] used_stand_modules, Dictionary<string,
{
sl.statements.AddElementFirst(units[0].IsConsoleApplicationVariableAssignExpr);
}
else if (SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info is compiled_variable_definition && units[0].IsConsoleApplicationVariableValue.constant_value)
{
bool is_console = true;

foreach (var ns in units[0].used_namespaces)
{
if (graph_modules.Contains(ns))
{
is_console = false;
break;
}
}
if (is_console)
{
var ccnf = SystemLibrary.SystemLibInitializer.ConfigVariable.sym_info as compiled_variable_definition;
basic_function_call bbfc = new basic_function_call(SystemLibrary.SystemLibrary.bool_assign as basic_function_node, null);
bbfc.parameters.AddElement(new static_compiled_variable_reference(ccnf.cont_type.find_in_type(TreeConverter.compiler_string_consts.IsConsoleApplicationVariableName)[0].sym_info as compiled_variable_definition, ccnf.cont_type, null));
bbfc.parameters.AddElement(new bool_const_node(true, null));
sl.statements.AddElement(bbfc);
}

}
for (int i = 0; i < units.Count; i++)
{
if (units[i].main_function != null)
Expand Down

0 comments on commit 80a757b

Please sign in to comment.