• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISourceLocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISourceLocation的典型用法代码示例。如果您正苦于以下问题:C# ISourceLocation类的具体用法?C# ISourceLocation怎么用?C# ISourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISourceLocation类属于命名空间,在下文中一共展示了ISourceLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Box

        /// <summary>
        /// Create code to box the given source value into the given type.
        /// </summary>
        public static RLRange Box(this IRLBuilder builder, ISourceLocation sequencePoint, RegisterSpec source, XTypeReference type, DexTargetPackage targetPackage, IRegisterAllocator frame)
        {
            if (type.IsPrimitive)
            {
                if (type.IsByte()) builder.Add(sequencePoint, RCode.Int_to_byte, source.Register, source.Register);
                else if (type.IsUInt16()) builder.Add(sequencePoint, RCode.Int_to_short, source.Register, source.Register);
                // Call appropriate valueOf method
                var boxedType = type.Module.TypeSystem.Object;
                var r = frame.AllocateTemp(boxedType.GetReference(targetPackage));
                var call = builder.Add(sequencePoint, RCode.Invoke_static, type.GetBoxValueOfMethod(), source.Registers);
                var last = builder.Add(sequencePoint, RCode.Move_result_object, r);
                return new RLRange(call, last, r);
            }
            if (type.IsGenericParameter)
            {
                var nop = builder.Add(sequencePoint, RCode.Nop);
                return new RLRange(nop, source);
            }
            XTypeDefinition typeDef ;
            if (type.TryResolve(out typeDef) && (typeDef.IsEnum))
            {
                // Call appropriate valueOf method
                /*var boxedType = type.Module.TypeSystem.Object;
                var r = frame.AllocateTemp(boxedType.GetReference(target, nsConverter));
                var call = builder.Add(sequencePoint, RCode.Invoke_static, typeDef.GetEnumUnderlyingType().GetBoxValueOfMethod(), source.Registers);
                var last = builder.Add(sequencePoint, RCode.Move_result_object, r);
                return new RLRange(call, last, r);*/
            }

            // Just cast
            var checkCast = builder.Add(sequencePoint, RCode.Check_cast, type.GetReference(targetPackage), source);
            return new RLRange(checkCast, source);
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:36,代码来源:RLBuilder.cs


示例2: Add

        /// <summary>
        /// Create and add an instruction.
        /// 
        /// This seems to be a dangerous overload, since it may hide the one below if operand is null.
        /// We can't remove it without checking all ~170 usages though...
        /// </summary>
        public static Instruction Add(this IRLBuilder builder, ISourceLocation sequencePoint, RCode opcode, params Register[] registers)
        {
            if(registers.Any(r=> r == null))
                throw new InvalidOperationException("Register must not be null. Wrong overload?");

            return builder.Add(sequencePoint, opcode, (object)null, registers);
        }
开发者ID:jakesays,项目名称:dot42,代码行数:13,代码来源:RLBuilder.cs


示例3: TranslationMessage

 public TranslationMessage(ISourceLocation loc, int code, string msg, bool isWarning)
 {
     this.loc = loc;
       this.code = code;
       this.msg = msg;
       this.isWarning = isWarning;
 }
开发者ID:edgar-pek,项目名称:VCDryad,代码行数:7,代码来源:TranslationMessage.cs


示例4: AddFieldForLocal

 internal FieldDeclaration AddFieldForLocal(SimpleName localName, Expression initialValue, ISourceLocation sourceLocation) {
   FieldDeclaration field = new FieldDeclaration(null, FieldDeclaration.Flags.Static, TypeMemberVisibility.Private, 
     TypeExpression.For(initialValue.Type), new NameDeclaration(localName.Name, localName.SourceLocation), null, sourceLocation);
   field.SetContainingTypeDeclaration(this, false);
   this.members.Add(field);
   this.localFieldFor.Add(localName.Name.UniqueKeyIgnoringCase, field.FieldDefinition);
   return field;
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:8,代码来源:TypeDeclarations.cs


示例5: GetNameDeclarationFor

 private NameDeclaration GetNameDeclarationFor(string name, ISourceLocation sourceLocation) 
   //^ ensures result.Value == name;
 {
   IName iname = this.nameTable.GetNameFor(name);
   NameDeclaration result = new NameDeclaration(iname, sourceLocation);
   //^ assume result.Value == name;
   return result;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:8,代码来源:Parser.cs


示例6: Parser

 internal Parser(Compilation compilation, ISourceLocation sourceLocation, List<IErrorMessage> scannerAndParserErrors) {
   this.compilation = compilation;
   this.nameTable = compilation.NameTable;
   this.scannerAndParserErrors = this.originalScannerAndParserErrors = scannerAndParserErrors;
   this.scanner = new Scanner(scannerAndParserErrors, sourceLocation, true);
   this.insideBlock = false;
   this.insideType = false;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:8,代码来源:Parser.cs


示例7: CreateMapping

 /// <summary>
 /// Initializes a mapping.
 /// </summary>
 public static AttributeAnnotationMapping CreateMapping(
     ISourceLocation sequencePoint,
     AssemblyCompiler compiler,
     DexTargetPackage targetPackage,
     TypeDefinition attributeType,
     ClassDefinition attributeClass)
 {
     return new AttributeAnnotationMapping(attributeType, attributeClass);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:12,代码来源:AttributeAnnotationInstanceBuilder.cs


示例8: Scanner

 public Scanner(List<IErrorMessage>/*?*/ scannerErrors, ISourceLocation sourceLocation, bool ignoreComments) {
   this.scannerErrors = scannerErrors;
   this.sourceLocation = sourceLocation;
   char[] buffer = new char[16];
   this.charsInBuffer = sourceLocation.CopyTo(0, buffer, 0, buffer.Length-1);
   this.buffer = buffer;
   this.endPos = this.startPos = 0;
   this.offset = 0;
   this.ignoreComments = ignoreComments;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:10,代码来源:Scanner.cs


示例9: Error_NameCollision

        protected void Error_NameCollision(ISourceLocation site, NameCollisionException exception)
        {
            // Build type string
            StringBuilder sb = new StringBuilder();
            sb.Append(AttributeHelpers.GetTypeName(exception.Types[0]).ToLower() + "s");
            for (int i = 1; i < exception.Types.Length - 1; i++) sb.Append(", " + AttributeHelpers.GetTypeName(exception.Types[i]).ToLower() + "s");
            if (exception.Types.Length > 1) sb.Append(" or " + AttributeHelpers.GetTypeName(exception.Types[exception.Types.Length - 1]).ToLower() + "s");

            errorReporter.Error(site, "\"{1}\" can refer to multiple {0}. Remove unused usings or prefix the name with namespace qualifier.", sb.ToString(), exception.Name);
        }
开发者ID:st9200,项目名称:soal-oslo,代码行数:10,代码来源:SoaLanguageParser.cs


示例10: HandleError

 private void HandleError(ISourceLocation errorLocation, Error error, params string[] messageParameters)
   // ^ modifies this.scannerAndParserErrors;
   //^ ensures this.currentToken == old(this.currentToken);
 {
   //^ Token oldToken = this.currentToken;
   if (this.originalScannerAndParserErrors == this.scannerAndParserErrors) {
   }
   this.scannerAndParserErrors.Add(new SpecSharpErrorMessage(errorLocation, (long)error, error.ToString(), messageParameters));
   //^ assume this.currentToken == oldToken;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:10,代码来源:Parser.cs


示例11: CcsErrorMessage

 /// <summary>
 /// Initializes a new instance of the error message
 /// </summary>
 /// <param name="resourceType"></param>
 /// <param name="sourceLocation"></param>
 /// <param name="errorCode"></param>
 /// <param name="messageKey"></param>
 /// <param name="relatedLocations"></param>
 /// <param name="messageArguments"></param>
 public CcsErrorMessage(
     Type resourceType,
     ISourceLocation sourceLocation,
     long errorCode,
     string messageKey,
     IEnumerable<ILocation> relatedLocations,
     string[] messageArguments)
     :base(sourceLocation, errorCode, messageKey, relatedLocations, messageArguments)
 {
     Contract.Requires(resourceType != null);
     this.resourceType = resourceType;
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:21,代码来源:CcsErrorMessage.cs


示例12: DelegateInstanceTypeBuilder

 /// <summary>
 /// Create the current type as class definition.
 /// </summary>
 internal DelegateInstanceTypeBuilder(
     ISourceLocation sequencePoint,
     AssemblyCompiler compiler, DexTargetPackage targetPackage,
     ClassDefinition delegateClass,
     XMethodDefinition invokeMethod, Prototype invokePrototype,
     XMethodDefinition calledMethod)
 {
     this.sequencePoint = sequencePoint;
     this.compiler = compiler;
     this.targetPackage = targetPackage;
     this.delegateClass = delegateClass;
     this.invokeMethod = invokeMethod;
     this.invokePrototype = invokePrototype;
     this.calledMethod = calledMethod;
     this.multicastDelegateClass = compiler.GetDot42InternalType("System", "MulticastDelegate").GetClassReference(targetPackage);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:19,代码来源:DelegateInstanceTypeBuilder.cs


示例13: GetOrCreateInstance

        /// <summary>
        /// Gets the instance type that calls the given method.
        /// Create if needed.
        /// </summary>
        public DelegateInstanceType GetOrCreateInstance(ISourceLocation sequencePoint, DexTargetPackage targetPackage, XMethodDefinition calledMethod)
        {
            DelegateInstanceType result;
            if (instances.TryGetValue(calledMethod, out result))
                return result;

            // Ensure prototype exists
            if (invokePrototype == null)
            {
                invokePrototype = PrototypeBuilder.BuildPrototype(compiler, targetPackage, interfaceClass, invokeMethod);
            }

            

            // Not found, build it.
            var builder = new DelegateInstanceTypeBuilder(sequencePoint, compiler, targetPackage, InterfaceClass, 
                                                          invokeMethod, invokePrototype, calledMethod);
            result = builder.Create();
            instances.Add(calledMethod, result);
            return result;
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:25,代码来源:DelegateType.cs


示例14: EnsureTemp

 /// <summary>
 /// Ensure the given value register is a temp register.
 /// If it is not, allocate a temp register an copy to it.
 /// </summary>
 public static RLRange EnsureTemp(this IRLBuilder builder, ISourceLocation sequencePoint, RegisterSpec value, IRegisterAllocator frame)
 {
     // Is temp?
     if (value.Register.Category == RCategory.Temp)
         return new RLRange(value);
     // No, allocate temp
     var tmp = frame.AllocateTemp(value.Type);
     Instruction ins;
     switch (value.Register.Type)
     {
         case RType.Object:
             ins = builder.Add(sequencePoint, RCode.Move_object, tmp.Register, value.Register);
             break;
         case RType.Wide:
             ins = builder.Add(sequencePoint, RCode.Move_wide, tmp.Register, value.Register);
             break;
         case RType.Value:
             ins = builder.Add(sequencePoint, RCode.Move, tmp.Register, value.Register);
             break;
         default:
             throw new ArgumentException("Unknown register type " + (int)value.Register.Type);
     }
     return new RLRange(ins, tmp);
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:28,代码来源:RLBuilder.cs


示例15: ConvertTypeBeforeStore

        /// <summary>
        /// Emit code (if needed) to convert a value from source type to destination type.
        /// This method is used in "store" opcodes such stloc, stfld, stsfld, call
        /// </summary>
        internal static RLRange ConvertTypeBeforeStore(this IRLBuilder builder, ISourceLocation sequencePoint, XTypeReference sourceType, XTypeReference destinationType, RegisterSpec source, DexTargetPackage targetPackage, IRegisterAllocator frame, AssemblyCompiler compiler, out bool converted)
        {
            converted = false;
            if (sourceType.IsSame(destinationType))
            {
                // Unsigned conversions
                if (sourceType.IsByte())
                {
                    var tmp = builder.EnsureTemp(sequencePoint, source, frame);
                    var ins = builder.Add(sequencePoint, RCode.Int_to_byte, tmp.Result, tmp.Result);
                    converted = true;
                    return new RLRange(tmp, ins, tmp.Result);
                }
                else if (sourceType.IsUInt16())
                {
                    var tmp = builder.EnsureTemp(sequencePoint, source, frame);
                    var ins = builder.Add(sequencePoint, RCode.Int_to_short, tmp.Result, tmp.Result);
                    converted = true;
                    return new RLRange(tmp, ins, tmp.Result);
                }
                return new RLRange(source);
            }

            if (sourceType.IsArray)
            {
                var compilerHelper = compiler.GetDot42InternalType(InternalConstants.CompilerHelperName).Resolve();
                var arrayType = targetPackage.DexFile.GetClass(targetPackage.NameConverter.GetConvertedFullName(compilerHelper));
                var sourceArrayElementType = ((XArrayType)sourceType).ElementType;
                if (destinationType.ExtendsIList())
                {
                    // Use ArrayHelper.AsList to convert
                    var convertMethodName = "AsList";
                    var convertMethod = arrayType.GetMethod(convertMethodName);
                    // Add code
                    var tmp = builder.EnsureTemp(sequencePoint, source, frame);
                    builder.Add(sequencePoint, RCode.Invoke_static, convertMethod, tmp.Result.Register);
                    var last = builder.Add(sequencePoint, RCode.Move_result_object, tmp.Result.Register);
                    converted = true;
                    return new RLRange(tmp, last, tmp.Result);
                }
                if (destinationType.ExtendsICollection())
                {
                    // Use ArrayHelper.AsCollection to convert
                    var convertMethodName = "AsCollection";
                    var convertMethod = arrayType.GetMethod(convertMethodName);
                    // Add code
                    var tmp = builder.EnsureTemp(sequencePoint, source, frame);
                    builder.Add(sequencePoint, RCode.Invoke_static, convertMethod, tmp.Result.Register);
                    var last = builder.Add(sequencePoint, RCode.Move_result_object, tmp.Result.Register);
                    converted = true;
                    return new RLRange(tmp, last, tmp.Result);
                }
                if (destinationType.ExtendsIEnumerable())
                {
                    // Use ArrayHelper.As...Enumerable to convert
                    var convertMethodName = "AsObjectEnumerable";
                    if (sourceArrayElementType.IsPrimitive)
                    {
                        if (sourceArrayElementType.IsBoolean()) convertMethodName = "AsBoolEnumerable";
                        else if (sourceArrayElementType.IsByte()) convertMethodName = "AsByteEnumerable";
                        else if (sourceArrayElementType.IsSByte()) convertMethodName = "AsSByteEnumerable";
                        else if (sourceArrayElementType.IsChar()) convertMethodName = "AsCharEnumerable";
                        else if (sourceArrayElementType.IsInt16()) convertMethodName = "AsInt16Enumerable";
                        else if (sourceArrayElementType.IsUInt16()) convertMethodName = "AsUInt16Enumerable";
                        else if (sourceArrayElementType.IsInt32()) convertMethodName = "AsInt32Enumerable";
                        else if (sourceArrayElementType.IsUInt32()) convertMethodName = "AsUInt32Enumerable";
                        else if (sourceArrayElementType.IsInt64()) convertMethodName = "AsInt64Enumerable";
                        else if (sourceArrayElementType.IsFloat()) convertMethodName = "AsFloatEnumerable";
                        else if (sourceArrayElementType.IsDouble()) convertMethodName = "AsDoubleEnumerable";
                        else throw new ArgumentOutOfRangeException("Unknown primitive array element type " + sourceArrayElementType);
                    }
                    var convertMethod = arrayType.GetMethod(convertMethodName);
                    // Add code
                    var tmp = builder.EnsureTemp(sequencePoint, source, frame);
                    builder.Add(sequencePoint, RCode.Invoke_static, convertMethod, tmp.Result.Register);
                    var last = builder.Add(sequencePoint, RCode.Move_result_object, tmp.Result.Register);
                    converted = true;
                    return new RLRange(tmp, last, tmp.Result);
                }
            }

            // Do not convert
            return new RLRange(source);
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:88,代码来源:RLBuilder.cs


示例16: Unbox

        /// <summary>
        /// Create code to unbox the given source value into the given type.
        /// </summary>
        public static RLRange Unbox(this IRLBuilder builder, ISourceLocation sequencePoint, RegisterSpec source, XTypeReference type, AssemblyCompiler compiler, DexTargetPackage targetPackage, IRegisterAllocator frame)
        {
            if (type.IsPrimitive)
            {
                RCode convertAfterCode;
                var rUnboxed = frame.AllocateTemp(type.GetReference(targetPackage));
                var unboxValueMethod = type.GetUnboxValueMethod(compiler, targetPackage, out convertAfterCode);
                var first = builder.Add(sequencePoint, RCode.Invoke_static, unboxValueMethod, source);
                var last = builder.Add(sequencePoint, type.MoveResult(), rUnboxed);
                if (convertAfterCode != RCode.Nop)
                {
                    last = builder.Add(sequencePoint, convertAfterCode, rUnboxed, rUnboxed);
                }

                return new RLRange(first, last, rUnboxed);
            }

            XTypeDefinition enumTypeDef;
            if (type.IsEnum(out enumTypeDef))
            {
                var rUnboxed = frame.AllocateTemp(type.GetReference(targetPackage));
                var unboxValueMethod = enumTypeDef.Methods.First(x => x.Name == NameConstants.Enum.UnboxMethodName).GetReference(targetPackage);
                var first = builder.Add(sequencePoint, RCode.Invoke_static, unboxValueMethod, source);
                var last = builder.Add(sequencePoint, type.MoveResult(), rUnboxed);
                return new RLRange(first, last, rUnboxed);                
            }

            if (!type.IsGenericParameter)
            {
                // Just cast
                var checkCast = builder.Add(sequencePoint, RCode.Check_cast, type.GetReference(targetPackage), source);
                return new RLRange(checkCast, source);
            }

            // Do nothing
            var nop = builder.Add(sequencePoint, RCode.Nop);
            return new RLRange(nop, source);
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:41,代码来源:RLBuilder.cs


示例17: Error_NameExists

        protected void Error_NameExists(ISourceLocation site, NameCollisionException exception)
        {
            // Build type string
            StringBuilder sb = new StringBuilder();
            sb.Append(AttributeHelpers.GetTypeName(exception.Types[0]).ToLower());
            for (int i = 1; i < exception.Types.Length - 1; i++) sb.Append(", " + AttributeHelpers.GetTypeName(exception.Types[i]).ToLower());
            if (exception.Types.Length > 1) sb.Append(" or " + AttributeHelpers.GetTypeName(exception.Types[exception.Types.Length - 1]).ToLower());

            errorReporter.Error(site, "A {0} with name \"{1}\" already exists.", sb.ToString(), exception.Name);
        }
开发者ID:st9200,项目名称:soal-oslo,代码行数:10,代码来源:SoaLanguageParser.cs


示例18: Error_InterfaceMismatch

 protected void Error_InterfaceMismatch(ISourceLocation site, System.Type ownerType)
 {
     errorReporter.Error(site, "Interface of endpoint and {0} does not match.", AttributeHelpers.GetTypeName(ownerType).ToLower());
 }
开发者ID:st9200,项目名称:soal-oslo,代码行数:4,代码来源:SoaLanguageParser.cs


示例19: UnboxGenericArray

 /// <summary>
 /// Create code to unbox the given source array of boxed type elements into an array of primitive elements.
 /// </summary>
 public static RLRange UnboxGenericArray(this IRLBuilder builder, ISourceLocation sequencePoint, RegisterSpec source, RegisterSpec boxedArray,
                                        XTypeReference type, DexTargetPackage targetPackage, IRegisterAllocator frame, AssemblyCompiler compiler)
 {
     var internalBoxingType = compiler.GetDot42InternalType("Boxing").Resolve();
     var ilUnboxMethod = internalBoxingType.Methods.First(x => x.EqualsName("UnboxTo") && (x.Parameters.Count == 2) && (x.Parameters[1].ParameterType.IsSame(type, true)));
     var unboxMethod = ilUnboxMethod.GetReference(targetPackage);
     var call = builder.Add(sequencePoint, RCode.Invoke_static, unboxMethod, boxedArray, source);
     return new RLRange(call, null);
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:12,代码来源:RLBuilder.cs


示例20: Add

 /// <summary>
 /// Create and add an instruction.
 /// </summary>
 public static Instruction Add(this IRLBuilder builder, ISourceLocation sequencePoint, RCode opcode, object operand, params Register[] registers)
 {
     return builder.Add(sequencePoint, opcode, operand, registers);
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:7,代码来源:RLBuilder.cs



注:本文中的ISourceLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISourceStream类代码示例发布时间:2022-05-24
下一篇:
C# ISourceInformationProvider类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap