Пример #1
0
    // Visit a namespace definition
    public void visit_namespace(NamespaceStmt namespace_stmt)
    {
        WavyNamespace wnamespace = new WavyNamespace((string)namespace_stmt.name.value, new Scope(this.local_scope));

        // Define the namespace in the local scope
        this.local_scope.define(wnamespace.name, wnamespace);
        // Execute the new namespace with the new scope
        execute_block(namespace_stmt.body, wnamespace.scope);
    }
 // Visit a namespace definition
 public void visit_namespace(NamespaceStmt namespace_stmt)
 {
     // Do we want namespace variables to be indipendent or have the previous scope? [new Scope(this.local_scope);]
     if (this.namespaces.ContainsKey((string)namespace_stmt.name.value))
     {
         throw new RuntimeException("Namespace with name '" + (string)namespace_stmt.name.value + "' already exists");
     }
     // Create a new scope for the given namespace, and execute the namespace code
     this.namespaces.Add((string)namespace_stmt.name.value, new Scope());
     execute_block(namespace_stmt.body, this.namespaces[(string)namespace_stmt.name.value]);
 }
    // Visit a namespace definition
    public void visit_namespace(NamespaceStmt namespace_stmt)
    {
        if (this.namespaces.ContainsKey((string)namespace_stmt.name.value))
        {
            throw new RuntimeException("Namespace with name '" + (string)namespace_stmt.name.value + "' already exists");
        }
        // Add a new namespace to the dicionary
        // Do we want namespace variables to be indipendent or have the previous scope? [new Scope(this.scoped);]
        this.namespaces.Add((string)namespace_stmt.name.value, new Stack <Dictionary <string, bool> >());
        // Save the old scope and set the current to the new namespace scope
        Stack <Dictionary <string, bool> > previous_scope = this.scopes;

        this.scopes = this.namespaces[(string)namespace_stmt.name.value];
        start_scope();
        resolve(namespace_stmt.body);
        // Restore the previous scope
        this.scopes = previous_scope;
    }
Пример #4
0
 // Visit a namespace definition
 public void visit_namespace(NamespaceStmt namespace_stmt)
 {
     declare(namespace_stmt.name);
     define(namespace_stmt.name);
     resolve(namespace_stmt.body);
 }