[Mono-list] runtime intrinsics
Daniel Stodden
stodden@in.tum.de
27 May 2002 02:32:02 +0200
--=-79+CO6YuGnxxHb6Od4xH
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
hi.
the following output is from a small test program built with csc but
trapped on mono. mint is segfaulting.
ahem, could someone provide me with a hint on _how_ to debug things like
these? how when are these types of errors triggered?
staring into loader.c and jit.c did not enlighten me much yet..
for the curious, uncomprehensive source code attached.
--snip--
(process:10299): ** WARNING **: Missing method Add in typeref index 93
(process:10299): ** ERROR **: file ../../../../mono/jit/jit.c: line 2508
(mono_analyze_stack): assertion failed: (cm)
aborting...
Trace/breakpoint trap
--snap--
--
___________________________________________________________________________
mailto:stodden@in.tum.de
--=-79+CO6YuGnxxHb6Od4xH
Content-Disposition: attachment; filename=testcodedom4.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=testcodedom4.cs; charset=ISO-8859-1
namespace Test {
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.CSharp;
public class TestCodeDom3
{
static void PopulateImports( object sender, EventArgs args )
{
CodeNamespace ns =3D (CodeNamespace)sender;
=09
CodeNamespaceImportCollection imports =3D ns.Imports;
=09
imports.Add( new CodeNamespaceImport( "System.Collections" ) );
}
static void AddArrayTypes( CodeMemberMethod method )
{
CodeTypeReference type;
type =3D new CodeTypeReference( new CodeTypeReference( "System.Int32", 3=
), 1 );
CodeArrayCreateExpression create =3D new CodeArrayCreateExpression( type=
);
create.Size =3D 42;
create.Initializers.Add( new CodePrimitiveExpression( 1 ) );
method.Statements.Add( new CodeVariableDeclarationStatement( type, "arra=
y1", create ) );
type =3D new CodeTypeReference( "System.Int32", 1 );
create =3D new CodeArrayCreateExpression( type );
method.Statements.Add( new CodeVariableDeclarationStatement( type, "arra=
y2", create ) );
=09
CodeTypeReference arrayType;
arrayType =3D new CodeTypeReference( "System.Int32", 2 );
type =3D new CodeTypeReference( arrayType, 1 );
create =3D new CodeArrayCreateExpression( type,=20
new CodeExpression[] {=20
new CodeArrayCreateExpression( arrayType,
new CodeExpression[] {=20
new CodePrimitiveExpression( 1 )
} ),
new CodeArrayCreateExpression( arrayType,
new CodeExpression[] {=20
new CodePrimitiveExpression( 2 )
} ),
new CodeArrayCreateExpression( arrayType,
new CodeExpression[] {=20
new CodePrimitiveExpression( 3 )
} )=20
} );
create.Size =3D 3;
method.Statements.Add( new CodeVariableDeclarationStatement( type, "arra=
y3", create ) );
arrayType =3D new CodeTypeReference( "System.Int32", 2 );
type =3D new CodeTypeReference( arrayType, 1 );
create =3D new CodeArrayCreateExpression( type, 2 );
method.Statements.Add( new CodeVariableDeclarationStatement( type, "arra=
y4", create ) );
}
static void AddTryCatch( CodeMemberMethod method )
{
method.Statements.Add( new CodeTryCatchFinallyStatement(
new CodeStatement[] {
new CodeAssignStatement( new CodeFieldReferenceExpression( new CodeThi=
sReferenceExpression(), "member" ),
new CodeBinaryOperatorExpression( new CodeCastExpression( "System.Int=
64", new CodeVariableReferenceExpression( "param" ) ),
CodeBinaryOperatorType.Add,
new CodePrimitiveExpression( 1 ) ) )
},
new CodeCatchClause[] {
new CodeCatchClause( "e",
new CodeTypeReference( "Exception" ),
new CodeExpressionStatement(=20
new CodeMethodInvokeExpression(=20
new CodeTypeReferenceExpression(new CodeTypeReference(typeof(Sys=
tem.Console))),
"WriteLine",=20
new CodePrimitiveExpression("an \"error\" occurred.") ) ) )
},
new CodeStatement[] {
new CodeCommentStatement( "give up" )=20
} ) );
}
static void PopulateStatements( object sender, EventArgs args )
{
CodeMemberMethod method =3D (CodeMemberMethod)sender;
AddArrayTypes( method );
AddTryCatch( method );
=09
method.Statements.Add( new CodeExpressionStatement( new CodeArrayIndexer=
Expression( new CodeBaseReferenceExpression(),
new CodeExpression[] {
new CodePrimitiveExpression( 10 ),
new CodeFieldReferenceExpression( new CodeThisReferenceEx=
pression(), "arrayindexer" )
} ) ) );
method.Statements.Add( new CodeExpressionStatement( new CodeIndexerExpre=
ssion( new CodeBaseReferenceExpression(),
new CodeExpression[] {
new CodePrimitiveExpression( 10 ),
new CodeFieldReferenceExpression( new CodeThisReference=
Expression(), "indexer" )
} ) ) );
method.Statements.Add( new CodeExpressionStatement( new CodeSnippetExpre=
ssion( "this" ) ) );
method.Statements.Add( new CodeExpressionStatement( new CodeSnippetExpre=
ssion( "\"this\"" ) ) );
}
static void PopulateTypes( object sender, EventArgs args )
{
CodeNamespace ns =3D (CodeNamespace)sender;
=09
CodeTypeDeclaration test =3D new CodeTypeDeclaration( "Test" );
#if false
test.TypeAttributes =3D=20
TypeAttributes.Public |=20
TypeAttributes.Sealed |
TypeAttributes.Abstract;
#endif
test.IsClass =3D true;
test.BaseTypes.Add( new CodeTypeReference( typeof(System.Array) ) );
test.BaseTypes.Add( new CodeTypeReference( typeof(System.Collections.ICo=
llection) ) );
test.BaseTypes.Add( new CodeTypeReference( "System.Collections.IEnumerab=
le" ) );
CodeMemberMethod method =3D new CodeMemberMethod();
method.Name =3D "GetEnumerator";
method.Parameters.Add( new CodeParameterDeclarationExpression( new CodeT=
ypeReference( typeof(System.Collections.ICollection) ), "collection" ) );
method.Parameters.Add( new CodeParameterDeclarationExpression( "System.I=
nt32", "value" ) );
CodeArrayCreateExpression array =3D new CodeArrayCreateExpression( new C=
odeTypeReference( "System.Int32", 2 ) );
#if false
array.Initializers.Add( new CodePrimitiveExpression( 1 ) );
array.Initializers.Add( new CodePrimitiveExpression( 2 ) );
array.Initializers.Add( new CodePrimitiveExpression( 3 ) );
#endif
method.Statements.Add( array );
method.Statements.Add( new CodeConditionStatement( new CodePrimitiveExpr=
ession( true ),
new CodeStatement[] { new CodeAssignStatement( new CodeVariable=
ReferenceExpression( "a" ), new CodePrimitiveExpression( 10 ) ) },
new CodeStatement[] { new CodeAssignStatement( new CodeVariable=
ReferenceExpression( "b" ), new CodePrimitiveExpression( "hello" ) ) } ) );
method.PrivateImplementationType =3D new CodeTypeReference( "IEnumerable=
" );
method.Attributes =3D MemberAttributes.Final | MemberAttributes.Static |=
MemberAttributes.Public;
method.CustomAttributes.Add( new CodeAttributeDeclaration( "Flags" ) );
method.CustomAttributes.Add( new CodeAttributeDeclaration( "Serializable=
" ) );
method.CustomAttributes.Add( new CodeAttributeDeclaration( "SomeOtherAtt=
ribute",=20
new CodeAttributeArgument( "name",=20
new CodeSnippetExpression( "value" ) ) ) );
test.Members.Add( method );
method =3D new CodeMemberMethod();
method.PopulateStatements +=3D new EventHandler( PopulateStatements );
method.Name =3D "MoveNext";
method.Attributes =3D MemberAttributes.Family;
method.CustomAttributes.Add( new CodeAttributeDeclaration( "System.Compo=
nentModel.ReadOnly", new CodeAttributeArgument( new CodeSnippetExpression( =
"true" ) ) ) );
test.Members.Add( method );
ns.Types.Add( test );
}
=09
static ICodeGenerator GetCodeGenerator()
{
CSharpCodeProvider provider =3D
new Microsoft.CSharp.CSharpCodeProvider();
ICodeGenerator codegen =3D provider.CreateGenerator();
=09
return codegen;
}
static void GenCode( CodeCompileUnit unit )
{
ICodeGenerator codegen =3D GetCodeGenerator();
IndentedTextWriter writer =3D
new IndentedTextWriter( System.Console.Out );
codegen.GenerateCodeFromCompileUnit( unit, writer, null );
}
static void Main( string[] argv )
{
CodeCompileUnit unit =3D new CodeCompileUnit();
CodeNamespaceCollection namespaces =3D unit.Namespaces;
CodeNamespace ns;
ns =3D new CodeNamespace( "System" );
namespaces.Add( ns );
ns.PopulateImports +=3D new EventHandler( PopulateImports );
ns =3D new CodeNamespace( "CodeDom.Test" );
namespaces.Add( ns );
ns.Comments.Add( new CodeCommentStatement( "This program is complete rub=
bish and only used for Testing System.CodeDom " +
"and System.CodeDom.Compiler implementatations.", true ) );
ns.PopulateImports +=3D new EventHandler( PopulateImports );
ns.PopulateTypes +=3D new EventHandler( PopulateTypes );
=09
GenCode( unit );
}
}
}
--=-79+CO6YuGnxxHb6Od4xH--