Package org.yinwang.pysonar.ast

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

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 Handler extends Node {

    public List<Node> exceptions;
    public Node binder;
    public Block body;


    public Handler(List<Node> exceptions, Node binder, Block body, String file, int start, int end) {
        super(file, start, end);
        this.binder = binder;
        this.exceptions = exceptions;
        this.body = body;
        addChildren(binder, body);
        addChildren(exceptions);
    }


    @NotNull
    @Override
    public Type transform(@NotNull State s) {
        Type typeval = Type.UNKNOWN;
        if (exceptions != null) {
            typeval = resolveUnion(exceptions, s);
        }
        if (binder != null) {
            Binder.bind(s, binder, typeval);
        }
        if (body != null) {
            return transformExpr(body, s);
        } else {
            return Type.UNKNOWN;
        }
    }


    @NotNull
    @Override
    public String toString() {
        return "(handler:" + start + ":" + exceptions + ":" + binder + ")";
    }

}
TOP

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

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.