public static void ResolveIdentifierExpression(IdentifierExpression identifier, Table.Table table, EmbeddedStatement initializedInBlock, bool checkInit = true) { if (identifier.IdentifierState == IdentifierExpression.State.Decl) { if (!table.PushIdentifier(identifier, table == GlobalTable.Table ? true : false)) { ReportError(new IdentifierIsAlreadyDeclared(identifier.Name, identifier.SourceContext)); } if (initializedInBlock != null) { table.InitializeInBlock(identifier, initializedInBlock); } } else { if (!table.CheckIdentifier(identifier.Name)) { ReportError(new IdentifierIsNotDeclared(identifier.Name, identifier.SourceContext)); } else { TableIdentifier tableIdentifier = table.FetchIdentifier(identifier.Name); identifier.Type = tableIdentifier.Type; //check for initialization in this block if (!table.IsInitializedInBlock(identifier, initializedInBlock) && checkInit && !tableIdentifier.InitializedGlobally) { ReportError(new IdentifierIsNotInitialized(identifier.Name, identifier.SourceContext)); } } } }
public static void ResolveAdressor(Expression adressor, EmbeddedStatement body, Table.Table table) { if (adressor is IdentifierExpression) { ResolveIdentifierExpression((IdentifierExpression)adressor, table, body, false); TableIdentifier tableIdentifier = table.FetchIdentifier(((IdentifierExpression)adressor).Name); if (tableIdentifier != null && tableIdentifier.IsGlobal) { tableIdentifier.InitializedGlobally = true; } else { table.InitializeInBlock((IdentifierExpression)adressor, body); } } else { ResolveArrayElement((ArrayElementExpression)adressor, table, true); } }