Package org.yinwang.pysonar.ast

Source Code of org.yinwang.pysonar.ast.With

package org.yinwang.pysonar.ast;

import org.jetbrains.annotations.NotNull;
import org.yinwang.pysonar.Binder;
import org.yinwang.pysonar.State;
import org.yinwang.pysonar.types.Type;

import java.util.List;


public class With extends Node {

    @NotNull
    public List<Withitem> items;
    public Block body;


    public With(@NotNull List<Withitem> items, Block body, String file, int start, int end) {
        super(file, start, end);
        this.items = items;
        this.body = body;
        addChildren(items);
        addChildren(body);
    }


    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        for (Withitem item : items) {
            Type val = transformExpr(item.context_expr, s);
            if (item.optional_vars != null) {
                Binder.bind(s, item.optional_vars, val);
            }
        }
        return transformExpr(body, s);
    }


    @NotNull
    @Override
    public String toString() {
        return "<With:" + items + ":" + body + ">";
    }

}
TOP

Related Classes of org.yinwang.pysonar.ast.With

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.