public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper labelHelper)
        {
            AppendNodeComment(fileManager);

            SyntaxTreeDeclarationNode declNode = symbolTable.GetDeclarationNodeLinkToSymbol(this.Identifier) as SyntaxTreeDeclarationNode;

            fileManager.Output.Append(Macro.LoadAccu(declNode.GetMemoryAddress()));
        }
        public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
        {
            AppendNodeComment(fileManager);
            this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            SyntaxTreeIdentNode identNode = this._children[0] as SyntaxTreeIdentNode;
            Symbol identSymbol = identNode.Identifier;
            SyntaxTreeDeclarationNode declNode = symbolTable.GetDeclarationNodeLinkToSymbol(identSymbol) as SyntaxTreeDeclarationNode;

            fileManager.Output.Append(Macro.StoreAccu(declNode.GetMemoryAddress()));
        }
Esempio n. 3
0
 bool CheckForDuplicateDeclarations(SymbolTable symbolTable)
 {
     return this._rootNode.RunDelegateForType(typeof(SyntaxTreeDeclarationNode), delegate(SyntaxTreeNode node)
     {
         SyntaxTreeDeclarationNode declNode = node as SyntaxTreeDeclarationNode;
         Symbol symbol = declNode.Identifier;
         if (!symbolTable.IsIdentifierSymbol(symbol))
         {
             string message = declNode.ContextErrorString("Declaration node contains not an identifier symbol.");
             Logger.Error(message);
             return false;
         }
         SyntaxTreeNode nodeFromSymbol = symbolTable.GetDeclarationNodeLinkToSymbol(symbol);
         if (nodeFromSymbol != declNode)
         {
             string message = declNode.ContextErrorString("Duplicate declaration of an identifier {0}.", symbolTable.GetRepresentationOfSymbol(symbol));
             Logger.Error(message);
             return false;
         }
         return true;
     });
 }
Esempio n. 4
0
 bool CheckForUndeclaredIdentifiers(SymbolTable symbolTable)
 {
     return this._rootNode.RunDelegateForType(typeof(SyntaxTreeIdentNode), delegate(SyntaxTreeNode node)
     {
         SyntaxTreeIdentNode identNode = node as SyntaxTreeIdentNode;
         Symbol symbol = identNode.Identifier;
         if (symbolTable.GetDeclarationNodeLinkToSymbol(symbol) == null)
         {
             string message = identNode.ContextErrorString("Identifier {0} was not declared.", symbolTable.GetRepresentationOfSymbol(symbol));
             Logger.Error(message);
             return false;
         }
         identNode.DeclarationNode = symbolTable.GetDeclarationNodeLinkToSymbol(symbol);
         return true;
     });
 }