コード例 #1
0
        IInstance DeclareIntrinsic(IFunctionIntrinsic functionIntrinsic, IParentedIdentifierScope scope)
        {
            var function = new IntrinsicFunctionInstance(functionIntrinsic);

            scope.Add(function);
            return(function);
        }
コード例 #2
0
        IInstance DeclareIntrinsic(IModuleIntrinsic moduleIntrinsic, IParentedIdentifierScope scope)
        {
            var module = new ModuleInstance(moduleIntrinsic.Name);

            DeclareIntrinsics(moduleIntrinsic.Children, new ParentedIdentifierScope(module.Identifiers)
            {
                Parent = scope
            });

            scope.Add(module);
            return(module);
        }
コード例 #3
0
        IInstance DeclareIntrinsic(ITypeModuleIntrinsic typeIntrinsic, IParentedIdentifierScope scope)
        {
            var module = new IntrinsicTypeModuleInstance(typeIntrinsic);

            DeclareIntrinsics(typeIntrinsic.Children, new ParentedIdentifierScope(module.Identifiers)
            {
                Parent = scope
            });

            AddTypeSizeDeclaration(typeIntrinsic.TypeSize, module, scope);
            // TODO: add Construct/Destruct
            // TODO: add conversions

            if (typeIntrinsic.NetType != null)
            {
                _netTypes[typeIntrinsic.NetType] = module;
            }
            scope.Add(module);
            return(module);
        }
コード例 #4
0
 internal Enumerator(IParentedIdentifierScope scope) : this()
 {
     _startIdentifierScope = scope;
     Reset();
 }
コード例 #5
0
        static void AddTypeSizeDeclaration(ulong typeIntrinsicTypeSize, IModuleInstance module, IParentedIdentifierScope scope)
        {
            var sizeType = module.Name == SizeTypeName
                ? module
                : (scope[SizeTypeName] as IModuleInstance);
            var sizeDefine = new VariableDeclaration {
                Name  = "size",
                Type  = sizeType,
                Value = new TypedValue {
                    Type = sizeType,
                    Data = BitConverter.GetBytes(typeIntrinsicTypeSize)
                }
            };
            var typeModule = new ModuleInstance(name: "type");

            typeModule.Identifiers.Add(new VariableInstance {
                Variable = sizeDefine
            });

            module.Identifiers.Add(typeModule);
        }
コード例 #6
0
 IList <IInstance> DeclareIntrinsics(IEnumerable <IIntrinsic> intrinsics, IParentedIdentifierScope scope)
 {
     return(intrinsics.Select(intrinsic => (IInstance)DeclareIntrinsic((dynamic)intrinsic, scope)).ToList());
 }