X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/7f83e1b208e87e3808b268303bb633a8fda203f5..c2ba7425955ae538e220cec79d9124756d1b4c8b:/src/typeInfo.h diff --git a/src/typeInfo.h b/src/typeInfo.h index 3914847..0fd4114 100644 --- a/src/typeInfo.h +++ b/src/typeInfo.h @@ -23,7 +23,7 @@ TypeInfo typeType(const Program & p, Type t) return result; } -TypeInfo typeExpr(const Program & p, const std::vector & globalNamespace, Expr e) +TypeInfo typeExpr(const Program & p, const std::vector & globalNamespace, std::shared_ptr globalCtx, Expr e) { TypeInfo result; @@ -43,7 +43,7 @@ TypeInfo typeExpr(const Program & p, const std::vector & globalNamespace } case ExprType::Method: { - TypeInfo tiCaller = typeExpr(p, globalNamespace, *e._method.expr); + TypeInfo tiCaller = typeExpr(p, globalNamespace, globalCtx, *e._method.expr); auto m = findStructMethod(p, e._method.methodName, tiCaller); if (!m.has_value()) throw "Unknown method"; @@ -61,32 +61,32 @@ TypeInfo typeExpr(const Program & p, const std::vector & globalNamespace } break; case ExprType::Paren: - result = typeExpr(p, globalNamespace, *e._paren.expr); + result = typeExpr(p, globalNamespace, globalCtx, *e._paren.expr); break; case ExprType::Dot: { auto sm = findStructMember(p, - typeExpr(p, globalNamespace, *e._dot.expr), e._dot.identifier); + typeExpr(p, globalNamespace, globalCtx, *e._dot.expr), e._dot.identifier); if (!sm.has_value()) throw "Unknown struct member"; result = typeType(p, sm.value().type); break; } case ExprType::PrefixOp: - result = typeExpr(p, globalNamespace, *e._prefixOp.expr); + result = typeExpr(p, globalNamespace, globalCtx, *e._prefixOp.expr); break; case ExprType::PostfixOp: - result = typeExpr(p, globalNamespace, *e._postfixOp.expr); + result = typeExpr(p, globalNamespace, globalCtx, *e._postfixOp.expr); break; case ExprType::BinaryOp: - result = typeExpr(p, globalNamespace, *e._binaryOp.lexpr); + result = typeExpr(p, globalNamespace, globalCtx, *e._binaryOp.lexpr); break; case ExprType::TernaryOp: - result = typeExpr(p, globalNamespace, *e._ternaryOp.rexprTrue); + result = typeExpr(p, globalNamespace, globalCtx, *e._ternaryOp.rexprTrue); break; case ExprType::Bracket: { - TypeInfo ti = typeExpr(p, globalNamespace, *e._brackets.lexpr); + TypeInfo ti = typeExpr(p, globalNamespace, globalCtx, *e._brackets.lexpr); if (!ti.type.modifiers.empty()) { result = ti; @@ -103,7 +103,7 @@ TypeInfo typeExpr(const Program & p, const std::vector & globalNamespace namespacePrefixes.insert(namespacePrefixes.end(), e._identifier.namespacePrefixes.begin(), e._identifier.namespacePrefixes.end()); - auto v = findVariable(p, e._identifier.identifier, namespacePrefixes); + auto v = findVariable(p, e._identifier.identifier, globalCtx); if (!v.has_value()) throw "Unknown variable"; result = typeType(p, v.value().type);