This commit is contained in:
parent
3050c13e9f
commit
a63a489968
|
|
@ -3498,6 +3498,11 @@ namespace PascalABCCompiler.PCU
|
|||
return new default_operator_node_as_constant(CreateDefaultOperator(), null);
|
||||
}
|
||||
|
||||
private sizeof_operator_as_constant CreateSizeOfOperatorAsConstant()
|
||||
{
|
||||
return new sizeof_operator_as_constant(CreateSizeOfOperator(), null);
|
||||
}
|
||||
|
||||
private expression_node CreateExpression(semantic_node_type snt)
|
||||
{
|
||||
//location loc = ReadDebugInfo();
|
||||
|
|
@ -3528,6 +3533,8 @@ namespace PascalABCCompiler.PCU
|
|||
return CreateCompiledConstructorCallAsConstant();
|
||||
case semantic_node_type.default_operator_node_as_constant:
|
||||
return CreateDefaultOperatorAsConstant();
|
||||
case semantic_node_type.sizeof_operator_as_constant:
|
||||
return CreateSizeOfOperatorAsConstant();
|
||||
case semantic_node_type.array_const:
|
||||
return CreateArrayConst();
|
||||
case semantic_node_type.record_const:
|
||||
|
|
|
|||
|
|
@ -3728,6 +3728,11 @@ namespace PascalABCCompiler.PCU
|
|||
VisitCompiledConstructorCall(node.method_call);
|
||||
}
|
||||
|
||||
private void VisitSizeOfOperatorAsConstant(sizeof_operator_as_constant node)
|
||||
{
|
||||
VisitSizeOfOperator(node.sizeof_operator);
|
||||
}
|
||||
|
||||
private void VisitCommonNamespaceFunctionCallNodeAsConstant(common_namespace_function_call_as_constant node)
|
||||
{
|
||||
VisitCommonNamespaceFunctionCall(node.method_call);
|
||||
|
|
@ -3763,6 +3768,8 @@ namespace PascalABCCompiler.PCU
|
|||
VisitCommonNamespaceFunctionCallNodeAsConstant((common_namespace_function_call_as_constant)en); break;
|
||||
case semantic_node_type.compiled_constructor_call_as_constant:
|
||||
VisitCompiledConstructorCallAsConstant((compiled_constructor_call_as_constant)en); break;
|
||||
case semantic_node_type.sizeof_operator_as_constant:
|
||||
VisitSizeOfOperatorAsConstant((sizeof_operator_as_constant)en); break;
|
||||
case semantic_node_type.array_const:
|
||||
VisitArrayConst((array_const)en); break;
|
||||
case semantic_node_type.record_const:
|
||||
|
|
|
|||
|
|
@ -11753,6 +11753,11 @@ namespace PascalABCCompiler.NETGenerator
|
|||
value.DefaultOperator.visit(this);
|
||||
}
|
||||
|
||||
public override void visit(ISizeOfOperatorAsConstant value)
|
||||
{
|
||||
value.SizeOfOperator.visit(this);
|
||||
}
|
||||
|
||||
public override void visit(ITypeOfOperatorAsConstant value)
|
||||
{
|
||||
value.TypeOfOperator.visit(this);
|
||||
|
|
|
|||
|
|
@ -661,6 +661,12 @@ namespace PascalABCCompiler.SemanticTree
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void visit(ISizeOfOperatorAsConstant value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ namespace PascalABCCompiler.SemanticTree
|
|||
void visit(ITypeOfOperatorAsConstant value);
|
||||
|
||||
void visit(ICommonStaticMethodCallNodeAsConstant value);
|
||||
}
|
||||
|
||||
void visit(ISizeOfOperatorAsConstant value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1897,6 +1897,14 @@ namespace PascalABCCompiler.SemanticTree
|
|||
}
|
||||
}
|
||||
|
||||
public interface ISizeOfOperatorAsConstant : IConstantNode
|
||||
{
|
||||
ISizeOfOperator SizeOfOperator
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICompiledConstructorCallAsConstant : IConstantNode
|
||||
{
|
||||
ICompiledConstructorCall MethodCall
|
||||
|
|
|
|||
26
TestSuite/sizeof2.pas
Normal file
26
TestSuite/sizeof2.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
type TRec = record
|
||||
a: integer;
|
||||
b: real;
|
||||
c: char;
|
||||
end;
|
||||
|
||||
type
|
||||
t1 = class
|
||||
o: t1;
|
||||
end;
|
||||
|
||||
const
|
||||
isize = sizeof(integer);
|
||||
rsize = sizeof(real);
|
||||
csize = sizeof(char);
|
||||
psize = sizeof(pointer);
|
||||
recsize = sizeof(TRec);
|
||||
classsize = sizeof(t1);
|
||||
begin
|
||||
assert(isize=4);
|
||||
assert(rsize=8);
|
||||
assert(csize=2);
|
||||
assert(psize=System.Runtime.InteropServices.Marshal.SizeOf(typeof(pointer)));
|
||||
assert(recsize=System.Runtime.InteropServices.Marshal.SizeOf(typeof(TRec)));
|
||||
assert(classsize > 0);
|
||||
end.
|
||||
27
TestSuite/units/u_sizeof2.pas
Normal file
27
TestSuite/units/u_sizeof2.pas
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
unit u_sizeof2;
|
||||
type TRec = record
|
||||
a: integer;
|
||||
b: real;
|
||||
c: char;
|
||||
end;
|
||||
|
||||
type
|
||||
t1 = class
|
||||
o: t1;
|
||||
end;
|
||||
|
||||
const
|
||||
isize = sizeof(integer);
|
||||
rsize = sizeof(real);
|
||||
csize = sizeof(char);
|
||||
psize = sizeof(pointer);
|
||||
recsize = sizeof(TRec);
|
||||
classsize = sizeof(t1);
|
||||
begin
|
||||
assert(isize=4);
|
||||
assert(rsize=8);
|
||||
assert(csize=2);
|
||||
assert(psize=System.Runtime.InteropServices.Marshal.SizeOf(typeof(pointer)));
|
||||
assert(recsize=System.Runtime.InteropServices.Marshal.SizeOf(typeof(TRec)));
|
||||
assert(classsize > 0);
|
||||
end.
|
||||
1
TestSuite/usesunits/use_sizeof2.pas
Normal file
1
TestSuite/usesunits/use_sizeof2.pas
Normal file
|
|
@ -0,0 +1 @@
|
|||
uses u_sizeof2; begin end.
|
||||
|
|
@ -15277,6 +15277,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
else if (expr is default_operator_node)
|
||||
constant = new default_operator_node_as_constant(expr as default_operator_node, null);
|
||||
else if (expr is sizeof_operator)
|
||||
constant = new sizeof_operator_as_constant(expr as sizeof_operator, null);
|
||||
else if (expr is typeof_operator && !is_const_section)
|
||||
constant = new typeof_operator_as_constant(expr as typeof_operator, null);
|
||||
else if (expr is common_static_method_call)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace PascalABCCompiler.TreeRealization
|
|||
pinvoke_node, basic_function_call_node_as_constant, compiled_static_field_reference_as_constant,
|
||||
common_namespace_event, indefinite_definition_node, indefinite_type, indefinite_function_call, indefinite_reference,
|
||||
wrapped_statement, wrapped_expression, default_operator_node_as_constant, double_question_colon_expression,
|
||||
typeof_operator_as_constant, common_static_method_call_node_as_constant
|
||||
typeof_operator_as_constant, common_static_method_call_node_as_constant, sizeof_operator_as_constant
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1292,6 +1292,59 @@ namespace PascalABCCompiler.TreeRealization
|
|||
}
|
||||
}
|
||||
|
||||
public class sizeof_operator_as_constant : constant_node, SemanticTree.ISizeOfOperatorAsConstant
|
||||
{
|
||||
private sizeof_operator _sizeof_operator;
|
||||
|
||||
public sizeof_operator sizeof_operator
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sizeof_operator;
|
||||
}
|
||||
set
|
||||
{
|
||||
_sizeof_operator = value;
|
||||
}
|
||||
}
|
||||
|
||||
public sizeof_operator_as_constant(sizeof_operator sizeof_operator, location loc)
|
||||
:
|
||||
base(sizeof_operator.type, loc)
|
||||
{
|
||||
_sizeof_operator = sizeof_operator;
|
||||
}
|
||||
|
||||
SemanticTree.ISizeOfOperator SemanticTree.ISizeOfOperatorAsConstant.SizeOfOperator
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sizeof_operator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Метод для обхода дерева посетителем.
|
||||
/// </summary>
|
||||
/// <param name="visitor">Класс - посетитель дерева.</param>
|
||||
public override void visit(SemanticTree.ISemanticVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Тип узла.
|
||||
/// </summary>
|
||||
public override semantic_node_type semantic_node_type
|
||||
{
|
||||
get
|
||||
{
|
||||
return semantic_node_type.sizeof_operator_as_constant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class compiled_constructor_call_as_constant : constant_node, SemanticTree.ICompiledConstructorCallAsConstant
|
||||
{
|
||||
private compiled_constructor_call _method_call;
|
||||
|
|
|
|||
|
|
@ -566,7 +566,6 @@ namespace VisualPascalABC
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
private delegate void EndDebuggerSessionDelegate();
|
||||
|
||||
private void EndDebuggerSessionSafe()
|
||||
|
|
|
|||
|
|
@ -1569,5 +1569,10 @@ namespace VisualPascalABCPlugins
|
|||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void visit(ISizeOfOperatorAsConstant value)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue