]> gitweb.ps.run Git - toc/blobdiff - src/typeInfo.h
function resolution, pre generics
[toc] / src / typeInfo.h
index 39148473ffec798787384177a4677267b0312b41..0fd41140fce03695ac2c3b6e50e365de771a0923 100644 (file)
@@ -23,7 +23,7 @@ TypeInfo typeType(const Program & p, Type t)
   return result;\r
 }\r
 \r
-TypeInfo typeExpr(const Program & p, const std::vector<string> & globalNamespace, Expr e)\r
+TypeInfo typeExpr(const Program & p, const std::vector<std::string> & globalNamespace, std::shared_ptr<Context> globalCtx, Expr e)\r
 {\r
   TypeInfo result;\r
 \r
@@ -43,7 +43,7 @@ TypeInfo typeExpr(const Program & p, const std::vector<string> & globalNamespace
   }\r
   case ExprType::Method:\r
   {\r
-    TypeInfo tiCaller = typeExpr(p, globalNamespace, *e._method.expr);\r
+    TypeInfo tiCaller = typeExpr(p, globalNamespace, globalCtx, *e._method.expr);\r
     auto m = findStructMethod(p, e._method.methodName, tiCaller);\r
     if (!m.has_value())\r
       throw "Unknown method";\r
@@ -61,32 +61,32 @@ TypeInfo typeExpr(const Program & p, const std::vector<string> & globalNamespace
     }\r
     break;\r
   case ExprType::Paren:\r
-    result = typeExpr(p, globalNamespace, *e._paren.expr);\r
+    result = typeExpr(p, globalNamespace, globalCtx, *e._paren.expr);\r
     break;\r
   case ExprType::Dot:\r
   {\r
     auto sm = findStructMember(p,\r
-        typeExpr(p, globalNamespace, *e._dot.expr), e._dot.identifier);\r
+        typeExpr(p, globalNamespace, globalCtx, *e._dot.expr), e._dot.identifier);\r
     if (!sm.has_value())\r
       throw "Unknown struct member";\r
     result = typeType(p, sm.value().type);\r
     break;\r
   }\r
   case ExprType::PrefixOp:\r
-    result = typeExpr(p, globalNamespace, *e._prefixOp.expr);\r
+    result = typeExpr(p, globalNamespace, globalCtx, *e._prefixOp.expr);\r
     break;\r
   case ExprType::PostfixOp:\r
-    result = typeExpr(p, globalNamespace, *e._postfixOp.expr);\r
+    result = typeExpr(p, globalNamespace, globalCtx, *e._postfixOp.expr);\r
     break;\r
   case ExprType::BinaryOp:\r
-    result = typeExpr(p, globalNamespace, *e._binaryOp.lexpr);\r
+    result = typeExpr(p, globalNamespace, globalCtx, *e._binaryOp.lexpr);\r
     break;\r
   case ExprType::TernaryOp:\r
-    result = typeExpr(p, globalNamespace, *e._ternaryOp.rexprTrue);\r
+    result = typeExpr(p, globalNamespace, globalCtx, *e._ternaryOp.rexprTrue);\r
     break;\r
   case ExprType::Bracket:\r
   {\r
-    TypeInfo ti = typeExpr(p, globalNamespace, *e._brackets.lexpr);\r
+    TypeInfo ti = typeExpr(p, globalNamespace, globalCtx, *e._brackets.lexpr);\r
     if (!ti.type.modifiers.empty())\r
     {\r
       result = ti;\r
@@ -103,7 +103,7 @@ TypeInfo typeExpr(const Program & p, const std::vector<string> & globalNamespace
     namespacePrefixes.insert(namespacePrefixes.end(),\r
       e._identifier.namespacePrefixes.begin(),\r
       e._identifier.namespacePrefixes.end());\r
-    auto v = findVariable(p, e._identifier.identifier, namespacePrefixes);\r
+    auto v = findVariable(p, e._identifier.identifier, globalCtx);\r
     if (!v.has_value())\r
       throw "Unknown variable";\r
     result = typeType(p, v.value().type);\r