IInstance DeclareIntrinsic(IFunctionIntrinsic functionIntrinsic, IParentedIdentifierScope scope) { var function = new IntrinsicFunctionInstance(functionIntrinsic); scope.Add(function); return(function); }
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); }
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); }
internal Enumerator(IParentedIdentifierScope scope) : this() { _startIdentifierScope = scope; Reset(); }
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); }
IList <IInstance> DeclareIntrinsics(IEnumerable <IIntrinsic> intrinsics, IParentedIdentifierScope scope) { return(intrinsics.Select(intrinsic => (IInstance)DeclareIntrinsic((dynamic)intrinsic, scope)).ToList()); }