本文整理汇总了C#中Emitter.TypeIsParent方法的典型用法代码示例。如果您正苦于以下问题:C# Emitter.TypeIsParent方法的具体用法?C# Emitter.TypeIsParent怎么用?C# Emitter.TypeIsParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emitter
的用法示例。
在下文中一共展示了Emitter.TypeIsParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileArray
public void CompileArray(Emitter.Emitter emitter)
{
// make sure it's an array
var type = emitter.GetArrayItemType(ExpressionPrefix.GetExpressionType(emitter));
if (type == "")
Error(Resources.errIndexingNotAnArray);
// make sure expression type matches array type
var exprType = Expression.GetExpressionType(emitter);
if (!emitter.TypeIsParent(type, exprType))
Error(String.Format(Resources.errAssignTypeMismatch, exprType, type));
ExpressionPrefix.Compile(emitter);
Index.Compile(emitter);
if (type == "complex")
{
// special case of valuetypes
var typeRef = emitter.ResolveType(type);
emitter.EmitLoadIndexAddress(typeRef);
Expression.Compile(emitter);
emitter.EmitSaveObject(typeRef);
}
else
{
Expression.Compile(emitter);
emitter.EmitSaveIndex(type);
}
}
示例2: Compile
public override void Compile(Emitter.Emitter emitter)
{
try
{
Resolve(emitter);
if (!emitter.TypeIsParent(IdentifierType, Expression.GetExpressionType(emitter)))
Error(String.Format(Resources.errAssignTypeMismatch, Expression.GetExpressionType(emitter), IdentifierType));
}
catch(CompilerException ex)
{
ex.AffixToLexem(Lexem);
throw;
}
switch (Kind)
{
case IdentifierKind.StaticField: Expression.Compile(emitter);
emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;
case IdentifierKind.Field: if (ExpressionPrefix != null)
ExpressionPrefix.Compile(emitter);
else
emitter.EmitLoadThis();
Expression.Compile(emitter);
emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;
case IdentifierKind.Variable: Expression.Compile(emitter);
emitter.EmitSaveVariable(emitter.CurrentMethod.Scope.Find(Name)); break;
case IdentifierKind.Parameter: Expression.Compile(emitter);
emitter.EmitSaveParameter(emitter.CurrentMethod.Parameters[Name].Id); break;
}
}
示例3: Compile
public override void Compile(Emitter.Emitter emitter)
{
var methodType = emitter.CurrentMethod.Type.Signature;
var exprType = "void";
if (Expression != null)
{
exprType = GetExpressionType(emitter);
Expression.Compile(emitter);
}
if(!emitter.TypeIsParent(methodType, exprType))
Error(String.Format(Resources.errReturnTypeMismatch, emitter.CurrentMethod.Name, emitter.CurrentMethod.Type.Signature, exprType));
emitter.EmitReturn();
}