本文整理汇总了C#中AstExpression类的典型用法代码示例。如果您正苦于以下问题:C# AstExpression类的具体用法?C# AstExpression怎么用?C# AstExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AstExpression类属于命名空间,在下文中一共展示了AstExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UnboxIfGeneric
private static void UnboxIfGeneric(XTypeReference type, AstExpression node, XTypeSystem typeSystem)
{
if (type.IsGenericParameter || type.IsGenericParameterArray())
{
var resultType = node.GetResultType();
if (resultType.IsByReference && !type.IsByReference)
{
var elementType = resultType.ElementType;
var clone = new AstExpression(node);
node.SetCode(AstCode.SimpleCastclass).SetArguments(clone).Operand = elementType;
}
else
{
if (TreatAsStruct(type, resultType))
{
ConvertUnboxStruct(node, resultType, typeSystem);
}
else
{
var clone = new AstExpression(node);
node.SetCode(AstCode.UnboxFromGeneric).SetArguments(clone).Operand = type;
}
}
}
}
开发者ID:jakesays,项目名称:dot42,代码行数:26,代码来源:GenericsConverter.cs
示例2: FindNestedAssignments
private void FindNestedAssignments(AstExpression expr, ExpressionToInfer parent)
{
foreach (var arg in expr.Arguments)
{
if (arg.Code == AstCode.Stloc)
{
var expressionToInfer = new ExpressionToInfer(arg);
allExpressions.Add(expressionToInfer);
FindNestedAssignments(arg, expressionToInfer);
var v = (AstVariable)arg.Operand;
if (v.Type == null)
{
assignmentExpressions[v].Add(expressionToInfer);
// the instruction that consumes the stloc result is handled as if it was reading the variable
parent.Dependencies.Add(v);
}
}
else
{
AstVariable v;
if (arg.Match(AstCode.Ldloc, out v) && (v.Type == null))
{
parent.Dependencies.Add(v);
}
FindNestedAssignments(arg, parent);
}
}
}
开发者ID:rfcclub,项目名称:dot42,代码行数:28,代码来源:TypeAnalysis.cs
示例3: Convert
/// <summary>
/// Optimize expressions
/// </summary>
public static void Convert(AstBlock ast)
{
var variableExpressions = ast.GetExpressions().Where(x => x.Operand is AstVariable).ToList();
var allVariables = variableExpressions.Select(x => (AstVariable)x.Operand).Distinct().ToList();
var allStructVariables = allVariables.Where(x => x.Type.IsStruct()).ToList();
var index = 0;
foreach (var iterator in allStructVariables)
{
var variable = iterator;
if (variable.IsThis || variable.IsParameter)
continue;
if (variableExpressions.Any(x => (x.Operand == variable) && (x.Code == AstCode.Stloc)))
continue;
// Get struct type
var structType = variable.Type.Resolve();
var defaultCtorDef = StructCallConverter.GetDefaultValueCtor(structType);
var defaultCtor = variable.Type.CreateReference(defaultCtorDef);
// Variable is not initialized
var newObjExpr = new AstExpression(ast.SourceLocation, AstCode.Newobj, defaultCtor).SetType(variable.Type);
var initExpr = new AstExpression(ast.SourceLocation, AstCode.Stloc, variable, newObjExpr).SetType(variable.Type);
ast.Body.Insert(index++, initExpr);
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:29,代码来源:InitializeStructVariablesConverter.cs
示例4: Convert
/// <summary>
/// Optimize expressions
/// </summary>
public static void Convert(AstNode ast)
{
// Expand typeof
foreach (var pair in ast.GetExpressionPairs())
{
var node = pair.Expression;
switch (node.Code)
{
case AstCode.Ldfld:
//case AstCode.Ldsfld: // NOT YET
{
var field = (XFieldReference) node.Operand;
var clone = new AstExpression(node);
node.SetCode(AstCode.UnboxFromGeneric).SetArguments(clone).Operand = field.FieldType;
}
break;
case AstCode.Call:
case AstCode.Calli:
case AstCode.Callvirt:
{
var method = (XMethodReference)node.Operand;
if ((!method.ReturnType.IsVoid()) && (pair.Parent != null))
{
var clone = new AstExpression(node);
node.SetCode(AstCode.UnboxFromGeneric).SetArguments(clone).Operand = method.ReturnType;
}
}
break;
}
}
}
开发者ID:rfcclub,项目名称:dot42,代码行数:34,代码来源:GenericsConverter.cs
示例5: ConvertCastclass
/// <summary>
/// Convert node with code Cast.
/// </summary>
private static void ConvertCastclass(AssemblyCompiler compiler, AstExpression node, XTypeSystem typeSystem)
{
var type = (XTypeReference) node.Operand;
if (type.IsSystemArray())
{
// Call cast method
var arrayHelper = compiler.GetDot42InternalType(InternalConstants.CompilerHelperName).Resolve();
var castToArray = arrayHelper.Methods.First(x => x.Name == "CastToArray");
var castToArrayExpr = new AstExpression(node.SourceLocation, AstCode.Call, castToArray, node.Arguments).SetType(type);
node.CopyFrom(castToArrayExpr);
return;
}
string castMethod = null;
if (type.IsSystemCollectionsIEnumerable())
{
castMethod = "CastToEnumerable";
}
else if (type.IsSystemCollectionsICollection())
{
castMethod = "CastToCollection";
}
else if (type.IsSystemCollectionsIList())
{
castMethod = "CastToList";
}
else if (type.IsSystemIFormattable())
{
castMethod = "CastToFormattable";
}
if (castMethod != null)
{
// Call cast method
var arrayHelper = compiler.GetDot42InternalType(InternalConstants.CompilerHelperName).Resolve();
var castToArray = arrayHelper.Methods.First(x => x.Name == castMethod);
// Call "(x instanceof T) ? (T)x : asMethod(x)"
// "instanceof x"
var instanceofExpr = new AstExpression(node.SourceLocation, AstCode.SimpleInstanceOf, type, node.Arguments[0]).SetType(typeSystem.Bool);
// CastX(x)
var castXExpr = new AstExpression(node.SourceLocation, AstCode.Call, castToArray, node.Arguments[0]).SetType(typeSystem.Object);
// T(x)
var txExpr = new AstExpression(node.SourceLocation, AstCode.SimpleCastclass, type, node.Arguments[0]).SetType(type);
// Combine
var conditional = new AstExpression(node.SourceLocation, AstCode.Conditional, type, instanceofExpr, txExpr, castXExpr).SetType(type);
node.CopyFrom(conditional);
return;
}
// Normal castclass
node.Code = AstCode.SimpleCastclass;
}
开发者ID:rfcclub,项目名称:dot42,代码行数:61,代码来源:CastConverter.cs
示例6: SimplifyLdObjAndStObj
static AstExpression SimplifyLdObjAndStObj(AstExpression expr, ref bool modified)
{
if (expr.Code == AstCode.Initobj)
{
expr.Code = AstCode.Stobj;
expr.Arguments.Add(new AstExpression(expr.SourceLocation, AstCode.DefaultValue, expr.Operand));
modified = true;
}
else if (expr.Code == AstCode.Cpobj)
{
expr.Code = AstCode.Stobj;
expr.Arguments[1] = new AstExpression(expr.SourceLocation, AstCode.Ldobj, expr.Operand, expr.Arguments[1]);
modified = true;
}
AstExpression arg, arg2;
XTypeReference type;
AstCode? newCode = null;
if (expr.Match(AstCode.Stobj, out type, out arg, out arg2))
{
switch (arg.Code)
{
case AstCode.Ldelema: newCode = AstCode.Stelem_Any; break;
case AstCode.Ldloca: newCode = AstCode.Stloc; break;
case AstCode.Ldflda: newCode = AstCode.Stfld; break;
case AstCode.Ldsflda: newCode = AstCode.Stsfld; break;
}
}
else if (expr.Match(AstCode.Ldobj, out type, out arg))
{
switch (arg.Code)
{
case AstCode.Ldelema: newCode = AstCode.Ldelem_Any; break;
case AstCode.Ldloca: newCode = AstCode.Ldloc; break;
case AstCode.Ldflda: newCode = AstCode.Ldfld; break;
case AstCode.Ldsflda: newCode = AstCode.Ldsfld; break;
}
}
if (newCode != null)
{
arg.Code = newCode.Value;
if (expr.Code == AstCode.Stobj)
{
arg.InferredType = expr.InferredType;
arg.ExpectedType = expr.ExpectedType;
arg.Arguments.Add(arg2);
}
arg.ILRanges.AddRange(expr.ILRanges);
modified = true;
return arg;
}
else
{
return expr;
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:55,代码来源:PeepholeTransform.cs
示例7: Convert
/// <summary>
/// Convert the result of the given node to uint8/uint16 if needed.
/// </summary>
private static void Convert(AstExpression node, AstCode convertCode, XTypeReference expectedType)
{
// Copy load expression
var clone = new AstExpression(node);
// Convert node
node.Code = convertCode;
node.SetArguments(clone);
node.Operand = null;
node.SetType(expectedType);
}
开发者ID:rfcclub,项目名称:dot42,代码行数:14,代码来源:ConvertBeforeStoreConversionConverter.cs
示例8: Exit
public RLRange Exit(AstCompilerVisitor compVisit, AstExpression node, List<RLRange> args)
{
var reg = GetMonitorRegister(compVisit, node);
if (reg != null)
{
var first = compVisit.Add(node.SourceLocation, RCode.Move_object, reg, args[0].Result);
var second = compVisit.Add(node.SourceLocation, RCode.Monitor_exit, reg);
return new RLRange(first, second, null);
}
// default handling
return new RLRange(compVisit.Add(node.SourceLocation, RCode.Monitor_exit, args[0].Result), null);
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:13,代码来源:MonitorManager.cs
示例9: TransformDecimalCtorToConstant
static bool TransformDecimalCtorToConstant(List<AstNode> body, AstExpression expr, int pos)
{
XMethodReference r;
List<AstExpression> args;
if (expr.Match(AstCode.Newobj, out r, out args) && r.DeclaringType.IsSystemDecimal())
{
//if (args.Count == 1)
//{
// int val;
// if (args[0].Match(AstCode.Ldc_I4, out val))
// {
// expr.Code = AstCode.Ldc_Decimal;
// expr.Operand = new decimal(val);
// expr.InferredType = r.DeclaringType;
// expr.Arguments.Clear();
// return true;
// }
//}
//else
if (args.Count == 5)
{
int lo, mid, hi, isNegative, scale;
if (expr.Arguments[0].Match(AstCode.Ldc_I4, out lo) &&
expr.Arguments[1].Match(AstCode.Ldc_I4, out mid) &&
expr.Arguments[2].Match(AstCode.Ldc_I4, out hi) &&
expr.Arguments[3].Match(AstCode.Ldc_I4, out isNegative) &&
expr.Arguments[4].Match(AstCode.Ldc_I4, out scale))
{
// convert to a static string conversion method.
var dec = new decimal(lo, mid, hi, isNegative != 0, (byte)scale);
var str = dec.ToString(CultureInfo.InvariantCulture);
expr.Code = AstCode.Call;
expr.Operand = r.DeclaringType.Resolve().Methods.First(p => p.Name == "FromInvariantString" && p.IsStatic && p.Parameters.Count == 1);
expr.Arguments.Clear();
expr.Arguments.Add(new AstExpression(expr.SourceLocation, AstCode.Ldstr, str));
expr.InferredType = r.DeclaringType;
return true;
}
}
}
bool modified = false;
foreach (AstExpression arg in expr.Arguments)
{
modified |= TransformDecimalCtorToConstant(null, arg, -1);
}
return modified;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:48,代码来源:PeepholeTransform.cs
示例10: GetMonitorRegister
public Register GetMonitorRegister(AstCompilerVisitor compVisit, AstExpression node)
{
// this code is still experimental, and possibly does not handle all cases.
var operand = node.Arguments[0].Operand;
Register reg = null;
if (operand is XFieldReference)
{
if (!_monitorUsage.TryGetValue(operand, out reg))
{
reg = compVisit.Frame.AllocateTemp(FrameworkReferences.Object);
_monitorUsage.Add(operand, reg);
}
}
return reg;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:MonitorManager.cs
示例11: Convert
/// <summary>
/// Optimize expressions
/// </summary>
public static void Convert(AstNode ast)
{
foreach (var node in ast.GetExpressions())
{
if (node.Code == AstCode.Ldloc)
{
var variable = (AstVariable) node.Operand;
var varType = variable.Type;
var expType = node.ExpectedType;
if ((expType != null) && (!varType.IsSame(expType)))
{
if (varType.IsByte() && (expType.IsChar() || expType.IsUInt16()))
{
var ldloc = new AstExpression(node);
var code = expType.IsUInt16() ? AstCode.Int_to_ushort : AstCode.Conv_U2;
node.CopyFrom(new AstExpression(node.SourceLocation, code, null, ldloc).SetType(expType));
}
}
}
else if (node.Code.IsCall())
{
var methodRef = (XMethodReference) node.Operand;
var returnType = methodRef.ReturnType;
var expType = node.ExpectedType;
if ((expType != null) && (!returnType.IsSame(expType)))
{
if (returnType.IsByte() && (expType.IsChar() || expType.IsUInt16()))
{
var ldloc = new AstExpression(node);
var code = expType.IsUInt16() ? AstCode.Int_to_ushort : AstCode.Conv_U2;
node.CopyFrom(new AstExpression(node.SourceLocation, code, null, ldloc).SetType(expType));
}
else if (returnType.IsUInt16() && expType.IsChar())
{
var ldloc = new AstExpression(node);
node.CopyFrom(new AstExpression(node.SourceLocation, AstCode.Conv_U2, null, ldloc).SetType(expType));
}
else if (returnType.IsChar() && expType.IsUInt16())
{
var ldloc = new AstExpression(node);
node.CopyFrom(new AstExpression(node.SourceLocation, AstCode.Int_to_ushort, null, ldloc).SetType(expType));
}
}
}
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:49,代码来源:LdLocWithConversionConverter.cs
示例12: ConvertIfNeeded
/// <summary>
/// Convert the result of the given node to uint8/uint16 if needed.
/// </summary>
private static void ConvertIfNeeded(AstExpression node, XTypeReference valueType, AstExpression parent)
{
AstCode convCode;
if (valueType.IsByte())
{
// Convert from int to uint8
convCode = AstCode.Int_to_ubyte;
}
else if (valueType.IsUInt16())
{
// Convert from int to uint16
convCode = AstCode.Int_to_ushort;
}
else if (valueType.IsChar())
{
// Convert from int to uint16
convCode = AstCode.Conv_U2;
}
else
{
// Do not convert
return;
}
// Avoid recursion
if ((parent != null) && (parent.Code == convCode))
return;
// Copy load expression
var clone = new AstExpression(node);
// Convert node
node.Code = convCode;
node.Arguments.Clear();
node.Arguments.Add(clone);
node.Operand = null;
node.InferredType = valueType;
// keep the expected type!
node.ExpectedType = clone.ExpectedType;
clone.ExpectedType = valueType;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:46,代码来源:ConvertAfterLoadConversionConverter.cs
示例13: ConvertIfNeeded
/// <summary>
/// Convert the given argument if it does not match the target type.
/// </summary>
private static void ConvertIfNeeded(AstExpression arg, XTypeReference targetType)
{
var argType = arg.GetResultType();
if (!targetType.IsSame(argType))
{
if (targetType.IsChar())
{
if (argType.IsUInt16() || argType.IsByte()) Convert(arg, AstCode.Conv_U2, targetType);
}
else if (targetType.IsUInt16())
{
if (argType.IsChar() || argType.IsByte()) Convert(arg, AstCode.Int_to_ushort, targetType);
}
else if (targetType.IsInt16())
{
if (argType.IsChar() || argType.IsByte()) Convert(arg, AstCode.Conv_I2, targetType);
}
}
}
开发者ID:rfcclub,项目名称:dot42,代码行数:22,代码来源:ConvertBeforeStoreConversionConverter.cs
示例14: Convert
/// <summary>
/// Optimize expressions
/// </summary>
public static void Convert(AstNode ast)
{
// Optimize brtrue (cxx(int, int)) expressions
foreach (var node in ast.GetExpressions(x => (x.Code == AstCode.Brtrue) || (x.Code == AstCode.Brfalse)))
{
var expr = node.Arguments[0];
if (expr.Code.IsCompare() && (expr.Arguments.Count == 2))
{
var arg1 = expr.Arguments[0];
var arg2 = expr.Arguments[1];
if (arg1.IsInt32() && arg2.IsInt32())
{
// Simplify
var code = (node.Code == AstCode.Brtrue) ? expr.Code : expr.Code.Reverse();
var newExpr = new AstExpression(expr.SourceLocation, code.ToBranch(), node.Operand, arg1, arg2);
node.CopyFrom(newExpr, true);
}
}
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:24,代码来源:BranchOptimizer.cs
示例15: AddFieldInitializationCode
/// <summary>
/// Add initialization code to the given constructor for non-initialized struct fields.
/// </summary>
private static void AddFieldInitializationCode(MethodSource ctor, AstBlock ast)
{
List<XFieldDefinition> fieldsToInitialize;
var declaringType = ctor.Method.DeclaringType;
var fieldsThatMayNeedInitialization = declaringType.Fields.Where(x => x.IsReachable && x.FieldType.IsEnum());
var index = 0;
if (ctor.Method.IsStatic)
{
fieldsToInitialize = fieldsThatMayNeedInitialization.Where(x => x.IsStatic && !IsInitialized(ast, x)).ToList();
foreach (var field in fieldsToInitialize)
{
var defaultExpr = new AstExpression(ast.SourceLocation, AstCode.DefaultValue, field.FieldType);
var initExpr = new AstExpression(ast.SourceLocation, AstCode.Stsfld, field, defaultExpr);
ast.Body.Insert(index++, initExpr);
}
}
else
{
// If there is a this ctor being called, we do not have to initialize here.
var thisCalls = ast.GetSelfAndChildrenRecursive<AstExpression>(x => (x.Code == AstCode.Call) && ((XMethodReference) x.Operand).DeclaringType.IsSame(declaringType));
if (thisCalls.Any(x => ((XMethodReference) x.Operand).Name == ".ctor"))
return;
fieldsToInitialize = fieldsThatMayNeedInitialization.Where(x => !x.IsStatic && !IsInitialized(ast, x)).ToList();
if (fieldsToInitialize.Any())
{
var baseCall = FindFirstBaseCtorCall(ast, declaringType);
var initExpressions = new List<AstExpression>();
foreach (var field in fieldsToInitialize)
{
var thisExpr = new AstExpression(ast.SourceLocation, AstCode.Ldthis, null);
var defaultExpr = new AstExpression(ast.SourceLocation, AstCode.DefaultValue, field.FieldType);
initExpressions.Add(new AstExpression(ast.SourceLocation, AstCode.Stfld, field, thisExpr, defaultExpr));
}
InsertAfter(ast, baseCall, initExpressions);
}
}
}
开发者ID:rfcclub,项目名称:dot42,代码行数:40,代码来源:MethodBodyCompiler.cs
示例16: Resolve
public string Resolve(AstExpression expr)
{
if (expr is AstMathExpression || expr is AstIntegerValueExpression)
{
return BuiltInTypes.INT;
}
else if (expr is AstBoolValueExpression || expr is AstBoolExpression)
{
return BuiltInTypes.BOOL;
}
else if (expr is AstIdArrayExpression)
{
return BuiltInTypes.INT;
}
else if (expr is AstIntegerListExpression)
{
return BuiltInTypes.INT;
}
else if (expr is AstIdExpression)
{
var s = table.Lookup((expr as AstIdExpression).Id);
if (s != null && Symbol.IsArray(s))
{
return BuiltInTypes.INT_ARRAY;
}
return GetSymbolType(expr, s, (expr as AstIdExpression).Id);
}
else if (expr is AstThisMethodCallExpression)
{
var key = (expr as AstThisMethodCallExpression).Name.Id;
var s = table.LookupFunction(key);
return GetSymbolType(expr, s, (expr as AstThisMethodCallExpression).Name.Id);
}
else if (expr is AstExternalMethodCallExpression)
{
var key = (expr as AstExternalMethodCallExpression).Target.Id + (expr as AstExternalMethodCallExpression).Name.Id;
var s = table.LookupFunction(key);
return GetSymbolType(expr, s, (expr as AstExternalMethodCallExpression).Target.Id + "." + (expr as AstExternalMethodCallExpression).Name.Id);
}
else if (expr is AstNegateUnaryExpr)
{
return BuiltInTypes.INT;
}
else if (expr is AstSimpleUnaryExpr)
{
return this.Resolve((expr as AstSimpleUnaryExpr).SimpleTerm);
}
else if (expr is AstSimpleTermExpr)
{
return this.Resolve((expr as AstSimpleTermExpr).Expr);
}
else if (expr is AstArrayIndex)
{
return this.Resolve((expr as AstArrayIndex).Expr);
}
else if (expr is AstExpressionList)
{
bool result = (expr as AstExpressionList).Expr.All(s => string.Equals(Resolve(s), "int"));
if (!result)
return "error";
else
return BuiltInTypes.INT;
}
else if (expr is AstStringLiteralExpression)
{
return BuiltInTypes.STRING;
}
else if (expr is AstComparison)
{
return BuiltInTypes.BOOL;
}
else
{
throw new Exception("Unknown expression type.");
}
}
开发者ID:nikita-vanyasin,项目名称:compiler,代码行数:78,代码来源:TypeResolver.cs
示例17: GetSymbolType
private string GetSymbolType(AstExpression expr, Symbol s, string id)
{
if (s == null)
{
var name = (s is CallableSymbol) ? " method" : " identifier";
var e = new SymbolNotFoundException("'" + id + "' " + name +" not found.");
e.Expr = expr;
e.Id = id;
throw e;
}
return s.Type;
}
开发者ID:nikita-vanyasin,项目名称:compiler,代码行数:13,代码来源:TypeResolver.cs
示例18: AndExpression
internal AndExpression(AstExpression left_child, AstExpression right_child) {
this.left_child = left_child;
this.right_child = right_child;
}
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:4,代码来源:PivotsExpression.cs
示例19: Convert
/// <summary>
/// Optimize expressions
/// </summary>
public static void Convert(AstNode ast, AssemblyCompiler compiler)
{
foreach (var node in ast.GetExpressions())
{
switch (node.Code)
{
// Optimize enum2int(ldsfld(enum-const))
// and enum2int(int.to.enum(xxx))
case AstCode.Enum_to_int:
case AstCode.Enum_to_long:
{
var arg = node.Arguments[0];
XFieldReference fieldRef;
if (arg.Match(AstCode.Ldsfld, out fieldRef))
{
XFieldDefinition field;
object value;
if (fieldRef.TryResolve(out field) && field.IsStatic && field.DeclaringType.IsEnum && field.TryGetEnumValue(out value))
{
// Replace with ldc_ix
var wide = (node.Code == AstCode.Enum_to_long);
node.SetCode(wide ? AstCode.Ldc_I8 : AstCode.Ldc_I4);
node.Operand = wide ? (object)XConvert.ToLong(value) : XConvert.ToInt(value);
node.Arguments.Clear();
}
}
else if (arg.Code == AstCode.Int_to_enum || arg.Code == AstCode.Long_to_enum)
{
var expectedType = node.ExpectedType;
node.CopyFrom(arg.Arguments[0]);
node.ExpectedType = expectedType;
}
}
break;
// optimize ceq/cne (int/long-to-enum(int), yyy)
case AstCode.Ceq:
case AstCode.Cne:
{
if (node.Arguments.Any(a=>IsToEnum(a.Code)))
{
// xx_to_enum is a quite costly operation when compared to enum-to-int,
// so convert this to an interger-only compare.
bool isLong = node.Arguments.Any(a => a.Code == AstCode.Long_to_enum);
foreach (var arg in node.Arguments)
{
if (IsToEnum(arg.Code))
{
arg.CopyFrom(arg.Arguments[0]);
arg.ExpectedType = isLong ? compiler.Module.TypeSystem.Long : compiler.Module.TypeSystem.Int;
}
else
{
Debug.Assert(arg.GetResultType().IsEnum());
var orig = new AstExpression(arg);
var convert = new AstExpression(arg.SourceLocation,
isLong ? AstCode.Enum_to_long : AstCode.Enum_to_int, null, orig);
convert.ExpectedType = isLong ? compiler.Module.TypeSystem.Long : compiler.Module.TypeSystem.Int;
arg.CopyFrom(convert);
}
}
}
break;
}
}
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:71,代码来源:EnumOptimizer.cs
示例20: TrySliceConvert
internal static slice TrySliceConvert(AstExpression expr)
{
if (expr is SliceExpression)
return new Slice((SliceExpression)expr);
if (expr is ConstantExpression && ((ConstantExpression)expr).Value == PythonOps.Ellipsis)
return Ellipsis.Instance;
if (expr is TupleExpression && ((TupleExpression)expr).IsExpandable)
return new ExtSlice(((Tuple)Convert(expr)).elts);
return null;
}
开发者ID:TerabyteX,项目名称:main,代码行数:10,代码来源:_ast.cs
注:本文中的AstExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论