Ejemplo n.º 1
0
        public override void Visit(VariableDecAssignAST variableDecAssign)
        {
            var identInfo = new IdentifierInfo
            {
                name           = variableDecAssign.Name,
                typeAST        = variableDecAssign.Type,
                position       = _currentNodePosition,
                scopeId        = _currentScope.id,
                isFunctionType = variableDecAssign.Type is FunctionTypeAST
            };

            AddIdentInfoToSymTable(identInfo);

            if (variableDecAssign.Type != null)
            {
                return;
            }

            IdentifiersToBeInferred.Add(new IdentExpr
            {
                identInfo = identInfo,
                expr      = variableDecAssign.ExpressionValue as BaseExprAST,
                file      = _symTable.FilePath
            });

            if (_currentScope.id != 0)
            {
                return;
            }

            GlobalIdentifiers.Add(variableDecAssign.Name);
        }
Ejemplo n.º 2
0
        public override void Visit(ConstantVariable constantVariable)
        {
            var identInfo = new IdentifierInfo
            {
                name       = constantVariable.VariableName,
                typeAST    = null,
                position   = _currentNodePosition,
                scopeId    = _currentScope.id,
                isConstant = true
            };

            AddIdentInfoToSymTable(identInfo);

            IdentifiersToBeInferred.Add(new IdentExpr
            {
                identInfo = identInfo,
                expr      = constantVariable.ExpressionValue,
                file      = _symTable.FilePath
            });

            if (_currentScope.id != 0)
            {
                return;
            }

            GlobalIdentifiers.Add(constantVariable.VariableName);
        }
        private async void InitializeGlobalIdentifiers()
        {
            using (NetworkModelGDAProxy gdaProxy = proxyFactory.CreateProxy <NetworkModelGDAProxy, INetworkModelGDAContract>(EndpointNames.NetworkModelGDAEndpoint))
            {
                if (gdaProxy == null)
                {
                    throw new NullReferenceException("InitializeGlobalIdentifiers => NetworkModelGDAProxy is null.");
                }

                List <ModelCode> propIds = new List <ModelCode> {
                    ModelCode.IDOBJ_GID
                };

                foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType)))
                {
                    if (dmsType == DMSType.MASK_TYPE || ignorableTypes.Contains(dmsType))
                    {
                        continue;
                    }

                    ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType);

                    int iteratorId;
                    int resourcesLeft;
                    int numberOfResources = 10000; //TODO: connfigurabilno

                    try
                    {
                        iteratorId    = gdaProxy.GetExtentValues(dmsTypesModelCode, propIds);
                        resourcesLeft = gdaProxy.IteratorResourcesLeft(iteratorId);

                        while (resourcesLeft > 0)
                        {
                            List <ResourceDescription> gdaResult = gdaProxy.IteratorNext(numberOfResources, iteratorId);

                            foreach (ResourceDescription rd in gdaResult)
                            {
                                Dispatcher.Invoke(() =>
                                {
                                    GlobalIdentifiers.Add(new GlobalIDBindingModel()
                                    {
                                        GID  = rd.Id,
                                        Type = dmsTypesModelCode.ToString(),
                                    });
                                });
                            }

                            resourcesLeft = gdaProxy.IteratorResourcesLeft(iteratorId);
                        }

                        gdaProxy.IteratorClose(iteratorId);
                    }
                    catch (Exception e)
                    {
                        string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", dmsTypesModelCode, e.Message);
                        Logger.LogError(message);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void Visit(FunctionProtoAST functionProto)
        {
            var functionType = functionProto.GetFunctionType();

            var identInfo = new IdentifierInfo
            {
                name           = functionProto.Name,
                position       = _currentNodePosition,
                typeAST        = functionType,
                scopeId        = _currentScope.id,
                isFunctionType = true
            };

            var identLocation = new IdentifierLocation
            {
                identifierName = identInfo.name,
                scopeId        = identInfo.scopeId
            };

            if (_symTable.IdentInfoDictionary.ContainsKey(identLocation))
            {
                throw new Exception(string.Format("Identifier {0} already declared in file {1} line {2}",
                                                  identInfo.name, _symTable.FilePath, _currentNodePosition));
            }

            _symTable.IdentInfoDictionary.Add(identLocation, identInfo);

            if (_currentScope.id == 0)
            {
                GlobalIdentifiers.Add(functionProto.Name);
            }

            if (functionProto.Args == null)
            {
                return;
            }

            for (var i = 0; i < functionProto.Args.Count; i++)
            {
                var functionArgument = functionProto.Args[i];

                identInfo = new IdentifierInfo
                {
                    name           = functionArgument.Name,
                    typeAST        = functionArgument.Type,
                    position       = _currentNodePosition,
                    scopeId        = _scopeIdGen + 1,
                    isFunctionType = functionArgument.Type is FunctionTypeAST,
                    isFnParam      = true,
                    paramIndex     = i
                };

                AddIdentInfoToSymTable(identInfo);
            }
        }
Ejemplo n.º 5
0
        private Task InitializeGlobalIdentifiers()
        {
            return(Task.Run(async() =>
            {
                var gdaClient = NetworkModelGdaClient.CreateClient();

                List <ModelCode> propIds = new List <ModelCode> {
                    ModelCode.IDOBJ_GID
                };

                foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType)))
                {
                    if (dmsType == DMSType.MASK_TYPE || ignorableTypes.Contains(dmsType))
                    {
                        continue;
                    }

                    ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType);

                    int iteratorId;
                    int resourcesLeft;
                    int numberOfResources = 10000; //MODO: connfigurabilno

                    try
                    {
                        iteratorId = await gdaClient.GetExtentValues(dmsTypesModelCode, propIds);
                        resourcesLeft = await gdaClient.IteratorResourcesLeft(iteratorId);

                        while (resourcesLeft > 0)
                        {
                            List <ResourceDescription> gdaResult = await gdaClient.IteratorNext(numberOfResources, iteratorId);

                            foreach (ResourceDescription rd in gdaResult)
                            {
                                Dispatcher.Invoke(() =>
                                {
                                    GlobalIdentifiers.Add(new GlobalIDBindingModel(rd.Id));
                                });
                            }

                            resourcesLeft = await gdaClient.IteratorResourcesLeft(iteratorId);
                        }

                        await gdaClient.IteratorClose(iteratorId);
                    }
                    catch (Exception e)
                    {
                        string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", dmsTypesModelCode, e.Message);
                        Logger.LogError(message);
                    }
                }
            }));
        }
Ejemplo n.º 6
0
        public override void Visit(VariableDecAST variableDec)
        {
            var identInfo = new IdentifierInfo
            {
                name           = variableDec.Name,
                typeAST        = variableDec.Type,
                position       = _currentNodePosition,
                scopeId        = _currentScope.id,
                isFunctionType = variableDec.Type is FunctionTypeAST
            };

            AddIdentInfoToSymTable(identInfo);

            if (_currentScope.id != 0)
            {
                return;
            }

            GlobalIdentifiers.Add(variableDec.Name);
        }
        private void ButtonRefreshGids_Click(object sender, RoutedEventArgs e)
        {
            GlobalIdentifiers.Clear();

            foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType)))
            {
                if (dmsType == DMSType.MASK_TYPE)
                {
                    continue;
                }

                ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType);
                tgda.GetExtentValues(dmsTypesModelCode, new List<ModelCode> { ModelCode.IDOBJ_GID }, null).ForEach(g => GlobalIdentifiers.Add(new GlobalIdentifierViewModel()
                {
                    GID = g,
                    Type = dmsTypesModelCode.ToString(),
                }));
            }

            SelectedGID = null;
        }
Ejemplo n.º 8
0
        public void ComputeGlobalLiveness(HashSet <Identifier> allRegisters)
        {
            foreach (var b in Blocks)
            {
                b.KilledIdentifiers.Clear();
                b.UpwardExposedIdentifiers.Clear();
                b.LiveOut.Clear();
                GlobalIdentifiers.UnionWith(b.ComputeKilledAndUpwardExposed());
            }

            // Compute live out for each block iteratively
            bool changed = true;

            while (changed)
            {
                changed = false;
                foreach (var b in Blocks)
                {
                    var temp = new HashSet <Identifier>();
                    foreach (var succ in b.Successors)
                    {
                        var equation = new HashSet <Identifier>(allRegisters);
                        foreach (var kill in succ.KilledIdentifiers)
                        {
                            equation.Remove(kill);
                        }
                        equation.IntersectWith(succ.LiveOut);
                        equation.UnionWith(succ.UpwardExposedIdentifiers);
                        temp.UnionWith(equation);
                    }
                    if (!b.LiveOut.SetEquals(temp))
                    {
                        b.LiveOut = temp;
                        changed   = true;
                    }
                }
            }
        }
 private void ButtonRefreshGids_Click(object sender, RoutedEventArgs e)
 {
     GlobalIdentifiers.Clear();
     InitializeGlobalIdentifiers();
 }