use of org.yinwang.pysonar.types.FunType in project pysonar2 by yinwang0.
the class TypeInferencer method visit.
@NotNull
@Override
public Type visit(FunctionDef node, State s) {
State env = s.getForwarding();
FunType fun = new FunType(node, env);
fun.table.setParent(s);
fun.table.setPath(s.extendPath(node.name.id));
fun.setDefaultTypes(visit(node.defaults, s));
Analyzer.self.addUncalled(fun);
Binding.Kind funkind;
if (node.isLamba) {
return fun;
} else {
if (s.stateType == State.StateType.CLASS) {
if ("__init__".equals(node.name.id)) {
funkind = CONSTRUCTOR;
} else {
funkind = METHOD;
}
} else {
funkind = FUNCTION;
}
Type outType = s.type;
if (outType instanceof ClassType) {
fun.setCls((ClassType) outType);
}
bind(s, node.name, fun, funkind);
return Types.CONT;
}
}
use of org.yinwang.pysonar.types.FunType in project pysonar2 by yinwang0.
the class TypeInferencer method bindMethodAttrs.
static void bindMethodAttrs(@NotNull FunType cl) {
if (cl.table.parent != null) {
Type cls = cl.table.parent.type;
if (cls != null && cls instanceof ClassType) {
addReadOnlyAttr(cl, "im_class", cls, CLASS);
addReadOnlyAttr(cl, "__class__", cls, CLASS);
addReadOnlyAttr(cl, "im_self", cls, ATTRIBUTE);
addReadOnlyAttr(cl, "__self__", cls, ATTRIBUTE);
}
}
}
Aggregations