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);
|
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)
|
private expression_node CreateExpression(semantic_node_type snt)
|
||||||
{
|
{
|
||||||
//location loc = ReadDebugInfo();
|
//location loc = ReadDebugInfo();
|
||||||
|
|
@ -3528,6 +3533,8 @@ namespace PascalABCCompiler.PCU
|
||||||
return CreateCompiledConstructorCallAsConstant();
|
return CreateCompiledConstructorCallAsConstant();
|
||||||
case semantic_node_type.default_operator_node_as_constant:
|
case semantic_node_type.default_operator_node_as_constant:
|
||||||
return CreateDefaultOperatorAsConstant();
|
return CreateDefaultOperatorAsConstant();
|
||||||
|
case semantic_node_type.sizeof_operator_as_constant:
|
||||||
|
return CreateSizeOfOperatorAsConstant();
|
||||||
case semantic_node_type.array_const:
|
case semantic_node_type.array_const:
|
||||||
return CreateArrayConst();
|
return CreateArrayConst();
|
||||||
case semantic_node_type.record_const:
|
case semantic_node_type.record_const:
|
||||||
|
|
|
||||||
|
|
@ -3728,6 +3728,11 @@ namespace PascalABCCompiler.PCU
|
||||||
VisitCompiledConstructorCall(node.method_call);
|
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)
|
private void VisitCommonNamespaceFunctionCallNodeAsConstant(common_namespace_function_call_as_constant node)
|
||||||
{
|
{
|
||||||
VisitCommonNamespaceFunctionCall(node.method_call);
|
VisitCommonNamespaceFunctionCall(node.method_call);
|
||||||
|
|
@ -3762,7 +3767,9 @@ namespace PascalABCCompiler.PCU
|
||||||
case semantic_node_type.common_namespace_function_call_node_as_constant:
|
case semantic_node_type.common_namespace_function_call_node_as_constant:
|
||||||
VisitCommonNamespaceFunctionCallNodeAsConstant((common_namespace_function_call_as_constant)en); break;
|
VisitCommonNamespaceFunctionCallNodeAsConstant((common_namespace_function_call_as_constant)en); break;
|
||||||
case semantic_node_type.compiled_constructor_call_as_constant:
|
case semantic_node_type.compiled_constructor_call_as_constant:
|
||||||
VisitCompiledConstructorCallAsConstant((compiled_constructor_call_as_constant)en); break;
|
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:
|
case semantic_node_type.array_const:
|
||||||
VisitArrayConst((array_const)en); break;
|
VisitArrayConst((array_const)en); break;
|
||||||
case semantic_node_type.record_const:
|
case semantic_node_type.record_const:
|
||||||
|
|
|
||||||
|
|
@ -11753,6 +11753,11 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
value.DefaultOperator.visit(this);
|
value.DefaultOperator.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void visit(ISizeOfOperatorAsConstant value)
|
||||||
|
{
|
||||||
|
value.SizeOfOperator.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
public override void visit(ITypeOfOperatorAsConstant value)
|
public override void visit(ITypeOfOperatorAsConstant value)
|
||||||
{
|
{
|
||||||
value.TypeOfOperator.visit(this);
|
value.TypeOfOperator.visit(this);
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,12 @@ namespace PascalABCCompiler.SemanticTree
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public virtual void visit(ISizeOfOperatorAsConstant value)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,25 +102,25 @@ namespace PascalABCCompiler.SemanticTree
|
||||||
|
|
||||||
void visit(IBoolConstantNode value);
|
void visit(IBoolConstantNode value);
|
||||||
|
|
||||||
void visit(IByteConstantNode value);
|
void visit(IByteConstantNode value);
|
||||||
|
|
||||||
void visit(IIntConstantNode value);
|
void visit(IIntConstantNode value);
|
||||||
|
|
||||||
void visit(ISByteConstantNode value);
|
void visit(ISByteConstantNode value);
|
||||||
|
|
||||||
void visit(IShortConstantNode value);
|
void visit(IShortConstantNode value);
|
||||||
|
|
||||||
void visit(IUShortConstantNode value);
|
void visit(IUShortConstantNode value);
|
||||||
|
|
||||||
void visit(IUIntConstantNode value);
|
void visit(IUIntConstantNode value);
|
||||||
|
|
||||||
void visit(IULongConstantNode value);
|
void visit(IULongConstantNode value);
|
||||||
|
|
||||||
void visit(ILongConstantNode value);
|
void visit(ILongConstantNode value);
|
||||||
|
|
||||||
void visit(IDoubleConstantNode value);
|
void visit(IDoubleConstantNode value);
|
||||||
|
|
||||||
void visit(IFloatConstantNode value);
|
void visit(IFloatConstantNode value);
|
||||||
|
|
||||||
void visit(ICharConstantNode value);
|
void visit(ICharConstantNode value);
|
||||||
|
|
||||||
|
|
@ -148,13 +148,13 @@ namespace PascalABCCompiler.SemanticTree
|
||||||
|
|
||||||
void visit(IConstantDefinitionNode value);
|
void visit(IConstantDefinitionNode value);
|
||||||
|
|
||||||
void visit(IClassConstantDefinitionNode value);
|
void visit(IClassConstantDefinitionNode value);
|
||||||
|
|
||||||
void visit(ICompiledClassConstantDefinitionNode value);
|
void visit(ICompiledClassConstantDefinitionNode value);
|
||||||
|
|
||||||
void visit(INamespaceConstantDefinitionNode value);
|
void visit(INamespaceConstantDefinitionNode value);
|
||||||
|
|
||||||
void visit(ICommonFunctionConstantDefinitionNode value);
|
void visit(ICommonFunctionConstantDefinitionNode value);
|
||||||
|
|
||||||
void visit(IPropertyNode value);
|
void visit(IPropertyNode value);
|
||||||
|
|
||||||
|
|
@ -189,122 +189,123 @@ namespace PascalABCCompiler.SemanticTree
|
||||||
void visit(ISimpleArrayNode value);
|
void visit(ISimpleArrayNode value);
|
||||||
|
|
||||||
void visit(ISimpleArrayIndexingNode value);
|
void visit(ISimpleArrayIndexingNode value);
|
||||||
|
|
||||||
void visit(IExternalStatementNode value);
|
void visit(IExternalStatementNode value);
|
||||||
|
|
||||||
void visit(IRefTypeNode value);
|
void visit(IRefTypeNode value);
|
||||||
|
|
||||||
void visit(IGetAddrNode value);
|
void visit(IGetAddrNode value);
|
||||||
|
|
||||||
void visit(IDereferenceNode value);
|
void visit(IDereferenceNode value);
|
||||||
|
|
||||||
void visit(IThrowNode value);
|
void visit(IThrowNode value);
|
||||||
|
|
||||||
void visit(ISwitchNode value);
|
void visit(ISwitchNode value);
|
||||||
|
|
||||||
void visit(ICaseVariantNode value);
|
void visit(ICaseVariantNode value);
|
||||||
|
|
||||||
void visit(ICaseRangeNode value);
|
void visit(ICaseRangeNode value);
|
||||||
|
|
||||||
void visit(INullConstantNode value);
|
void visit(INullConstantNode value);
|
||||||
|
|
||||||
void visit(IUnsizedArray value);
|
void visit(IUnsizedArray value);
|
||||||
|
|
||||||
void visit(IRuntimeManagedMethodBody value);
|
void visit(IRuntimeManagedMethodBody value);
|
||||||
|
|
||||||
void visit(IAsNode value);
|
void visit(IAsNode value);
|
||||||
|
|
||||||
void visit(IIsNode value);
|
void visit(IIsNode value);
|
||||||
|
|
||||||
void visit(ISizeOfOperator value);
|
void visit(ISizeOfOperator value);
|
||||||
|
|
||||||
void visit(ITypeOfOperator value);
|
void visit(ITypeOfOperator value);
|
||||||
|
|
||||||
void visit(IExitProcedure value);
|
void visit(IExitProcedure value);
|
||||||
|
|
||||||
void visit(ITryBlockNode value);
|
void visit(ITryBlockNode value);
|
||||||
|
|
||||||
void visit(IExceptionFilterBlockNode value);
|
void visit(IExceptionFilterBlockNode value);
|
||||||
|
|
||||||
void visit(IArrayConstantNode value);
|
void visit(IArrayConstantNode value);
|
||||||
|
|
||||||
void visit(IStatementsExpressionNode value);
|
void visit(IStatementsExpressionNode value);
|
||||||
|
|
||||||
void visit(IQuestionColonExpressionNode value);
|
void visit(IQuestionColonExpressionNode value);
|
||||||
|
|
||||||
void visit(IRecordConstantNode value);
|
|
||||||
|
|
||||||
void visit(ILabelNode value);
|
void visit(IRecordConstantNode value);
|
||||||
|
|
||||||
void visit(ILabeledStatementNode value);
|
void visit(ILabelNode value);
|
||||||
|
|
||||||
void visit(IGotoStatementNode value);
|
void visit(ILabeledStatementNode value);
|
||||||
|
|
||||||
void visit(ICompiledStaticMethodCallNodeAsConstant value);
|
void visit(IGotoStatementNode value);
|
||||||
|
|
||||||
void visit(ICompiledConstructorCallAsConstant value);
|
void visit(ICompiledStaticMethodCallNodeAsConstant value);
|
||||||
|
|
||||||
void visit(ICommonNamespaceFunctionCallNodeAsConstant value);
|
void visit(ICompiledConstructorCallAsConstant value);
|
||||||
|
|
||||||
void visit(IEnumConstNode value);
|
|
||||||
|
|
||||||
void visit(IForeachNode value);
|
void visit(ICommonNamespaceFunctionCallNodeAsConstant value);
|
||||||
|
|
||||||
void visit(ILockStatement value);
|
void visit(IEnumConstNode value);
|
||||||
|
|
||||||
void visit(ILocalBlockVariableNode value);
|
void visit(IForeachNode value);
|
||||||
|
|
||||||
void visit(ILocalBlockVariableReferenceNode value);
|
|
||||||
|
|
||||||
void visit(IRethrowStatement value);
|
|
||||||
|
|
||||||
void visit(IForeachBreakNode value);
|
|
||||||
|
|
||||||
void visit(IForeachContinueNode value);
|
|
||||||
|
|
||||||
void visit(INamespaceConstantReference value);
|
|
||||||
|
|
||||||
void visit(IFunctionConstantReference value);
|
|
||||||
|
|
||||||
void visit(ICommonConstructorCallAsConstant value);
|
|
||||||
|
|
||||||
void visit(IArrayInitializer value);
|
|
||||||
|
|
||||||
void visit(ICommonEventNode value);
|
|
||||||
|
|
||||||
void visit(IEventNode value);
|
|
||||||
|
|
||||||
void visit(ICompiledEventNode value);
|
|
||||||
|
|
||||||
void visit(IStaticEventReference value);
|
|
||||||
|
|
||||||
void visit(INonStaticEventReference value);
|
|
||||||
|
|
||||||
void visit(IRecordInitializer value);
|
|
||||||
|
|
||||||
void visit(IDefaultOperatorNode value);
|
void visit(ILockStatement value);
|
||||||
|
|
||||||
void visit(IAttributeNode value);
|
|
||||||
|
|
||||||
void visit(IPInvokeStatementNode value);
|
|
||||||
|
|
||||||
void visit(IBasicFunctionCallNodeAsConstant value);
|
|
||||||
|
|
||||||
void visit(ICompiledStaticFieldReferenceNodeAsConstant value);
|
void visit(ILocalBlockVariableNode value);
|
||||||
|
|
||||||
void visit(ILambdaFunctionNode value);
|
void visit(ILocalBlockVariableReferenceNode value);
|
||||||
|
|
||||||
void visit(ILambdaFunctionCallNode value);
|
void visit(IRethrowStatement value);
|
||||||
|
|
||||||
void visit(ICommonNamespaceEventNode value);
|
void visit(IForeachBreakNode value);
|
||||||
|
|
||||||
void visit(IDefaultOperatorNodeAsConstant value);
|
void visit(IForeachContinueNode value);
|
||||||
|
|
||||||
|
void visit(INamespaceConstantReference value);
|
||||||
|
|
||||||
|
void visit(IFunctionConstantReference value);
|
||||||
|
|
||||||
|
void visit(ICommonConstructorCallAsConstant value);
|
||||||
|
|
||||||
|
void visit(IArrayInitializer value);
|
||||||
|
|
||||||
|
void visit(ICommonEventNode value);
|
||||||
|
|
||||||
|
void visit(IEventNode value);
|
||||||
|
|
||||||
|
void visit(ICompiledEventNode value);
|
||||||
|
|
||||||
|
void visit(IStaticEventReference value);
|
||||||
|
|
||||||
|
void visit(INonStaticEventReference value);
|
||||||
|
|
||||||
|
void visit(IRecordInitializer value);
|
||||||
|
|
||||||
|
void visit(IDefaultOperatorNode value);
|
||||||
|
|
||||||
|
void visit(IAttributeNode value);
|
||||||
|
|
||||||
|
void visit(IPInvokeStatementNode value);
|
||||||
|
|
||||||
|
void visit(IBasicFunctionCallNodeAsConstant value);
|
||||||
|
|
||||||
|
void visit(ICompiledStaticFieldReferenceNodeAsConstant value);
|
||||||
|
|
||||||
|
void visit(ILambdaFunctionNode value);
|
||||||
|
|
||||||
|
void visit(ILambdaFunctionCallNode value);
|
||||||
|
|
||||||
|
void visit(ICommonNamespaceEventNode value);
|
||||||
|
|
||||||
|
void visit(IDefaultOperatorNodeAsConstant value);
|
||||||
|
|
||||||
void visit(IDoubleQuestionColonExpressionNode value);
|
void visit(IDoubleQuestionColonExpressionNode value);
|
||||||
|
|
||||||
void visit(ITypeOfOperatorAsConstant value);
|
void visit(ITypeOfOperatorAsConstant value);
|
||||||
|
|
||||||
void visit(ICommonStaticMethodCallNodeAsConstant 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
|
public interface ICompiledConstructorCallAsConstant : IConstantNode
|
||||||
{
|
{
|
||||||
ICompiledConstructorCall MethodCall
|
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.
|
||||||
|
|
@ -15107,9 +15107,9 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
AddError(loc, "CONSTANT_EXPRESSION_EXPECTED");
|
AddError(loc, "CONSTANT_EXPRESSION_EXPECTED");
|
||||||
}
|
}
|
||||||
else if (expr is common_namespace_function_call)
|
else if (expr is common_namespace_function_call)
|
||||||
{
|
{
|
||||||
common_namespace_function_call cnfc=expr as common_namespace_function_call;
|
common_namespace_function_call cnfc = expr as common_namespace_function_call;
|
||||||
foreach (expression_node el in cnfc.parameters)
|
foreach (expression_node el in cnfc.parameters)
|
||||||
convert_strong_to_constant_node(el, el.type, false, false, cnfc.location);
|
convert_strong_to_constant_node(el, el.type, false, false, cnfc.location);
|
||||||
//if (cnfc.function_node.namespace_node == context.converted_namespace)
|
//if (cnfc.function_node.namespace_node == context.converted_namespace)
|
||||||
|
|
@ -15119,7 +15119,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
else if (expr is basic_function_call)
|
else if (expr is basic_function_call)
|
||||||
{
|
{
|
||||||
basic_function_call cnfc=expr as basic_function_call;
|
basic_function_call cnfc = expr as basic_function_call;
|
||||||
//if (cnfc.function_node.namespace_node == context.converted_namespace)
|
//if (cnfc.function_node.namespace_node == context.converted_namespace)
|
||||||
// throw new ConstantExpressionExpected(loc);
|
// throw new ConstantExpressionExpected(loc);
|
||||||
foreach (expression_node el in cnfc.parameters)
|
foreach (expression_node el in cnfc.parameters)
|
||||||
|
|
@ -15128,69 +15128,69 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
else if (expr is typed_expression)
|
else if (expr is typed_expression)
|
||||||
{
|
{
|
||||||
expr = convertion_data_and_alghoritms.convert_type(expr, tn);
|
expr = convertion_data_and_alghoritms.convert_type(expr, tn);
|
||||||
if (expr is common_constructor_call)
|
if (expr is common_constructor_call)
|
||||||
{
|
{
|
||||||
constant = new common_constructor_call_as_constant(expr as common_constructor_call, null);
|
constant = new common_constructor_call_as_constant(expr as common_constructor_call, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (expr is typed_expression)
|
if (expr is typed_expression)
|
||||||
{
|
{
|
||||||
if (const_def_type != null)
|
if (const_def_type != null)
|
||||||
{
|
{
|
||||||
expr = convertion_data_and_alghoritms.convert_type(expr, const_def_type);
|
expr = convertion_data_and_alghoritms.convert_type(expr, const_def_type);
|
||||||
tn = const_def_type;
|
tn = const_def_type;
|
||||||
constant = new common_constructor_call_as_constant(expr as common_constructor_call, null);
|
constant = new common_constructor_call_as_constant(expr as common_constructor_call, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base_function_call bfc = ((expr as typed_expression).type as delegated_methods).proper_methods[0];
|
base_function_call bfc = ((expr as typed_expression).type as delegated_methods).proper_methods[0];
|
||||||
common_type_node del =
|
common_type_node del =
|
||||||
convertion_data_and_alghoritms.type_constructor.create_delegate(context.get_delegate_type_name(), bfc.simple_function_node.return_value_type, bfc.simple_function_node.parameters, context.converted_namespace, null);
|
convertion_data_and_alghoritms.type_constructor.create_delegate(context.get_delegate_type_name(), bfc.simple_function_node.return_value_type, bfc.simple_function_node.parameters, context.converted_namespace, null);
|
||||||
context.converted_namespace.types.AddElement(del);
|
context.converted_namespace.types.AddElement(del);
|
||||||
tn = del;
|
tn = del;
|
||||||
expr = convertion_data_and_alghoritms.explicit_convert_type(expr, del);
|
expr = convertion_data_and_alghoritms.explicit_convert_type(expr, del);
|
||||||
expr.type = tn;
|
expr.type = tn;
|
||||||
constant = new common_constructor_call_as_constant(expr as common_constructor_call, loc);
|
constant = new common_constructor_call_as_constant(expr as common_constructor_call, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (expr is namespace_constant_reference)
|
else if (expr is namespace_constant_reference)
|
||||||
{
|
{
|
||||||
constant = (expr as namespace_constant_reference).constant.const_value;
|
constant = (expr as namespace_constant_reference).constant.const_value;
|
||||||
convertion_data_and_alghoritms.check_convert_type(constant,tn,expr.location);
|
convertion_data_and_alghoritms.check_convert_type(constant, tn, expr.location);
|
||||||
if ((tn.type_special_kind == SemanticTree.type_special_kind.set_type || tn.type_special_kind == SemanticTree.type_special_kind.base_set_type) && tn.element_type != null)
|
if ((tn.type_special_kind == SemanticTree.type_special_kind.set_type || tn.type_special_kind == SemanticTree.type_special_kind.base_set_type) && tn.element_type != null)
|
||||||
{
|
{
|
||||||
ordinal_type_interface oti = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
|
ordinal_type_interface oti = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
|
||||||
if (oti != null)
|
if (oti != null)
|
||||||
{
|
{
|
||||||
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as common_namespace_function_node,null);
|
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as common_namespace_function_node, null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(oti.lower_value.get_constant_copy(null));
|
cmc.parameters.AddElement(oti.lower_value.get_constant_copy(null));
|
||||||
cmc.parameters.AddElement(oti.upper_value.get_constant_copy(null));
|
cmc.parameters.AddElement(oti.upper_value.get_constant_copy(null));
|
||||||
cmc.ret_type = tn;
|
cmc.ret_type = tn;
|
||||||
constant = new common_namespace_function_call_as_constant(cmc,null);
|
constant = new common_namespace_function_call_as_constant(cmc, null);
|
||||||
}
|
}
|
||||||
else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.short_string)
|
else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.short_string)
|
||||||
{
|
{
|
||||||
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as common_namespace_function_node,null);
|
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as common_namespace_function_node, null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(new int_const_node((tn.element_type as short_string_type_node).Length,null));
|
cmc.parameters.AddElement(new int_const_node((tn.element_type as short_string_type_node).Length, null));
|
||||||
cmc.ret_type = tn;
|
cmc.ret_type = tn;
|
||||||
constant = new common_namespace_function_call_as_constant(cmc,null);
|
constant = new common_namespace_function_call_as_constant(cmc, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (tn.type_special_kind == SemanticTree.type_special_kind.short_string)
|
if (tn.type_special_kind == SemanticTree.type_special_kind.short_string)
|
||||||
{
|
{
|
||||||
/*common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as common_namespace_function_node,null);
|
/*common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as common_namespace_function_node,null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(new int_const_node((tn as short_string_type_node).Length,null));*/
|
cmc.parameters.AddElement(new int_const_node((tn as short_string_type_node).Length,null));*/
|
||||||
expression_node cmc = convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as function_node,null,convertion_data_and_alghoritms.convert_type(expr,SystemLibrary.SystemLibrary.string_type),new int_const_node((tn as short_string_type_node).Length,null));
|
expression_node cmc = convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as function_node, null, convertion_data_and_alghoritms.convert_type(expr, SystemLibrary.SystemLibrary.string_type), new int_const_node((tn as short_string_type_node).Length, null));
|
||||||
constant = new common_namespace_function_call_as_constant(cmc as common_namespace_function_call,null);
|
constant = new common_namespace_function_call_as_constant(cmc as common_namespace_function_call, null);
|
||||||
}
|
}
|
||||||
/*expression_node e = convertion_data_and_alghoritms.convert_type(constant.get_constant_copy(expr.location), tn);
|
/*expression_node e = convertion_data_and_alghoritms.convert_type(constant.get_constant_copy(expr.location), tn);
|
||||||
switch (e.semantic_node_type)
|
switch (e.semantic_node_type)
|
||||||
{
|
{
|
||||||
case semantic_node_type.compiled_constructor_call:
|
case semantic_node_type.compiled_constructor_call:
|
||||||
|
|
@ -15200,7 +15200,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
constant = e as constant_node;
|
constant = e as constant_node;
|
||||||
break;
|
break;
|
||||||
}*/
|
}*/
|
||||||
/*if (constant.get_object_value() != null)
|
/*if (constant.get_object_value() != null)
|
||||||
{
|
{
|
||||||
//if (const_def_type != null)
|
//if (const_def_type != null)
|
||||||
{
|
{
|
||||||
|
|
@ -15232,43 +15232,43 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
return constant;
|
return constant;
|
||||||
}
|
}
|
||||||
else if (expr is function_constant_reference)
|
else if (expr is function_constant_reference)
|
||||||
{
|
{
|
||||||
constant = (expr as function_constant_reference).constant.const_value;
|
constant = (expr as function_constant_reference).constant.const_value;
|
||||||
convertion_data_and_alghoritms.check_convert_type(constant,tn,expr.location);
|
convertion_data_and_alghoritms.check_convert_type(constant, tn, expr.location);
|
||||||
if ((tn.type_special_kind == SemanticTree.type_special_kind.set_type || tn.type_special_kind == SemanticTree.type_special_kind.base_set_type) && tn.element_type != null)
|
if ((tn.type_special_kind == SemanticTree.type_special_kind.set_type || tn.type_special_kind == SemanticTree.type_special_kind.base_set_type) && tn.element_type != null)
|
||||||
{
|
{
|
||||||
ordinal_type_interface oti = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
|
ordinal_type_interface oti = tn.element_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
|
||||||
if (oti != null)
|
if (oti != null)
|
||||||
{
|
{
|
||||||
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as common_namespace_function_node,null);
|
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipFunction.sym_info as common_namespace_function_node, null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(oti.lower_value.get_constant_copy(null));
|
cmc.parameters.AddElement(oti.lower_value.get_constant_copy(null));
|
||||||
cmc.parameters.AddElement(oti.upper_value.get_constant_copy(null));
|
cmc.parameters.AddElement(oti.upper_value.get_constant_copy(null));
|
||||||
cmc.ret_type = tn;
|
cmc.ret_type = tn;
|
||||||
constant = new common_namespace_function_call_as_constant(cmc,null);
|
constant = new common_namespace_function_call_as_constant(cmc, null);
|
||||||
}
|
}
|
||||||
else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.short_string)
|
else if (tn.element_type.type_special_kind == SemanticTree.type_special_kind.short_string)
|
||||||
{
|
{
|
||||||
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as common_namespace_function_node,null);
|
common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringInSetFunction.sym_info as common_namespace_function_node, null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(new int_const_node((tn.element_type as short_string_type_node).Length,null));
|
cmc.parameters.AddElement(new int_const_node((tn.element_type as short_string_type_node).Length, null));
|
||||||
cmc.ret_type = tn;
|
cmc.ret_type = tn;
|
||||||
constant = new common_namespace_function_call_as_constant(cmc,null);
|
constant = new common_namespace_function_call_as_constant(cmc, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (tn.type_special_kind == SemanticTree.type_special_kind.short_string)
|
if (tn.type_special_kind == SemanticTree.type_special_kind.short_string)
|
||||||
{
|
{
|
||||||
/*common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as common_namespace_function_node,null);
|
/*common_namespace_function_call cmc = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as common_namespace_function_node,null);
|
||||||
cmc.parameters.AddElement(expr);
|
cmc.parameters.AddElement(expr);
|
||||||
cmc.parameters.AddElement(new int_const_node((tn as short_string_type_node).Length,null));*/
|
cmc.parameters.AddElement(new int_const_node((tn as short_string_type_node).Length,null));*/
|
||||||
expression_node cmc = convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as function_node,null,convertion_data_and_alghoritms.convert_type(expr,SystemLibrary.SystemLibrary.string_type),new int_const_node((tn as short_string_type_node).Length,null));
|
expression_node cmc = convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.ClipShortStringProcedure.sym_info as function_node, null, convertion_data_and_alghoritms.convert_type(expr, SystemLibrary.SystemLibrary.string_type), new int_const_node((tn as short_string_type_node).Length, null));
|
||||||
constant = new common_namespace_function_call_as_constant(cmc as common_namespace_function_call,null);
|
constant = new common_namespace_function_call_as_constant(cmc as common_namespace_function_call, null);
|
||||||
}
|
}
|
||||||
return constant;
|
return constant;
|
||||||
}
|
}
|
||||||
else if (expr is static_compiled_variable_reference && !(expr as static_compiled_variable_reference).var.IsLiteral)
|
else if (expr is static_compiled_variable_reference && !(expr as static_compiled_variable_reference).var.IsLiteral)
|
||||||
{
|
{
|
||||||
|
|
@ -15277,6 +15277,8 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
}
|
}
|
||||||
else if (expr is default_operator_node)
|
else if (expr is default_operator_node)
|
||||||
constant = new default_operator_node_as_constant(expr as default_operator_node, null);
|
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)
|
else if (expr is typeof_operator && !is_const_section)
|
||||||
constant = new typeof_operator_as_constant(expr as typeof_operator, null);
|
constant = new typeof_operator_as_constant(expr as typeof_operator, null);
|
||||||
else if (expr is common_static_method_call)
|
else if (expr is common_static_method_call)
|
||||||
|
|
@ -15289,7 +15291,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
constant = new common_static_method_call_as_constant(csmc, null);
|
constant = new common_static_method_call_as_constant(csmc, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
pinvoke_node, basic_function_call_node_as_constant, compiled_static_field_reference_as_constant,
|
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,
|
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,
|
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>
|
/// <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
|
public class compiled_constructor_call_as_constant : constant_node, SemanticTree.ICompiledConstructorCallAsConstant
|
||||||
{
|
{
|
||||||
private compiled_constructor_call _method_call;
|
private compiled_constructor_call _method_call;
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,6 @@ namespace VisualPascalABC
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private delegate void EndDebuggerSessionDelegate();
|
private delegate void EndDebuggerSessionDelegate();
|
||||||
|
|
||||||
private void EndDebuggerSessionSafe()
|
private void EndDebuggerSessionSafe()
|
||||||
|
|
|
||||||
|
|
@ -1569,5 +1569,10 @@ namespace VisualPascalABCPlugins
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void visit(ISizeOfOperatorAsConstant value)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue