public virtual bool VisitSourceUnit(SourceUnit unit) { VisitNodes(unit.Namespaces); VisitNodes(unit.Statements); return true; }
public override bool VisitSourceUnit(SourceUnit unit) { base.VisitSourceUnit(unit); ProcessNodesInQueue(); return true; }
public override bool VisitSourceUnit(SourceUnit unit) { nodeStack.Push( CurrentNode.Nodes.Add("SourceUnit") ); CurrentNode.Tag = unit; base.VisitSourceUnit(unit); nodeStack.Pop(); return true; }
public override bool VisitSourceUnit(SourceUnit unit) { NamespaceGraph nsGraph = unit.SymbolTable.TypeGraphView.DefineNamespace("Castle.Rook.Code"); unit.SymbolTable.CurrentNamespace = nsGraph; TypeDefinitionStatement typeDef = new TypeDefinitionStatement(unit.SymbolTable, AccessLevel.Private, String.Format("Global{0}", globalClassesCount++)); unit.SymbolTable.CurrentTypeDefinition = typeDef.SymbolTable.CurrentNamespace.AddTransientType( typeDef ); return base.VisitSourceUnit(unit); }
private void DeclareAndPopulateGlobalSourceUnit(CompilationUnit unit) { SourceUnit globalUnit = new SourceUnit(unit, "<global>"); TypeDefinitionStatement globalType = new TypeDefinitionStatement( AccessLevel.Public, "RookGlobal" ); globalUnit.Statements.Add( globalType ); MethodDefinitionStatement entryPoint = new MethodDefinitionStatement( AccessLevel.Public ); entryPoint.Name = "self.main"; foreach(SourceUnit sunit in unit.SourceUnits) { foreach(IStatement stmt in sunit.Statements) { if (stmt.StatementType == StatementType.TypeDefinition) continue; stmt.Parent.RemoveChild( stmt ); if (stmt.StatementType == StatementType.MethodDef) { (stmt as MethodDefinitionStatement).IsStatic = true; } if (stmt.StatementType == StatementType.MultipleVarDeclaration) { // TODO: Ensure no instance vars defined } if (stmt.StatementType == StatementType.ExpressionStmt || stmt.StatementType == StatementType.MultipleVarDeclaration ) { entryPoint.Statements.Add( stmt ); } else { globalType.Statements.Add( stmt ); } } } if (entryPoint.Statements.Count != 0) { globalType.Statements.Add( entryPoint ); // Might be necessary // unit.EntryPointMethod = entryPoint; } unit.SourceUnits.Add(globalUnit); }
public override bool VisitSourceUnit(SourceUnit unit) { currentFileName = unit.Filename; return base.VisitSourceUnit(unit); }
public SourceUnit sourceUnit( CompilationUnit cunit ) //throws RecognitionException, TokenStreamException { SourceUnit unit; topLevelScope = cunit.DefiningSymbolTable; unit = new SourceUnit(cunit, getFilename()); PushScope(unit, ScopeType.SourceUnit); nothing(); { switch ( LA(1) ) { case LITERAL_namespace: { namespace_declaration(unit.Namespaces); break; } case EOF: case CLASS: case DO: case DEF: case BEGIN: case NUM_INT: case NUM_FLOAT: case NUM_LONG: case STATEMENT_END: case IDENT: case STATICIDENT: case INSTIDENT: case LITERAL_self: case LPAREN: case LITERAL_require: case LITERAL_redo: case LITERAL_break: case LITERAL_next: case LITERAL_retry: case LITERAL_lambda: case LCURLY: case LITERAL_raise: case LITERAL_yield: case LITERAL_not: case LNOT: case PLUS: case MINUS: case BNOT: case LBRACK: case LITERAL_base: case STRING_LITERAL: case CHAR_LITERAL: { suite(unit.Statements); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } nothing(); match(Token.EOF_TYPE); if (0==inputState.guessing) { cunit.SourceUnits.Add(unit); PopScope(); if (!ErrorReport.HasErrors && scopes.Count != 0) ErrorReport.Error("Invalid scope count. " + "Something seems to be very wrong. Contact Castle's team and report the " + "code that caused this error."); } return unit; }