public void Execute() { foreach (IDeclaration variable in currentClass.Declarations) { if (variable is VariableDeclarationTemplate) { VariableDeclarationTemplate cVar = (VariableDeclarationTemplate)variable; Memory.Add(cVar.Name, new MemoryVar(cVar.Name, GetValue(cVar.DefaultValue))); } } RunMembers(currentClass.Statements); }
private void ReadVariableDeclaration() { char currentChar = (char)mReader.Peek(); VariableDeclarationTemplate variableDeclaration = new VariableDeclarationTemplate(); variableDeclaration.Name = string.Empty; StringBuilder variableType = new StringBuilder(); while (currentChar != CharDefinitions.EndDirective) { currentChar = (char)mReader.Read(); if (currentChar == CharDefinitions.EqualsOperator) { string valueStr = string.Empty; bool stop = false; while (!stop) { currentChar = (char)mReader.Read(); if (currentChar == CharDefinitions.VariableExpression) { stop = true; } if (char.IsDigit(currentChar)) { stop = true; } if (currentChar == CharDefinitions.StringDeclarator) { stop = true; } } while (currentChar != CharDefinitions.EndDirective) { valueStr += currentChar; currentChar = (char)mReader.Peek(); mReader.Read(); } variableDeclaration.DefaultValue = ReadArgValue(valueStr); } else if (char.IsLetter(currentChar)) { variableDeclaration.Name += currentChar; variableType.Append(currentChar); } } mClass.Declarations.Add(variableDeclaration); }
public override void Observe(VHDLCompilerInterface compiler) { string typeName = compiler.TypeDictionary[mVariable.Type]; string variableName = mVariable.Identifier; VariableDeclarationTemplate template = null; if (mVariable.DefaultValue != null) { string defValue = VHDLOperandGenerator.GetOperand(mVariable.DefaultValue, compiler); template = new VariableDeclarationTemplate(typeName, variableName, defValue); } else { template = new VariableDeclarationTemplate(typeName, variableName); } compiler.ObjectDictionary.AddItem(mVariable, variableName); declarationText = template.TransformText(); }