public Function(SmclType smclType, string name, IList<Typed> @params, IList<Stmt> @stmts) { SmclType = smclType; _name = name; _params = @params; _stmts = @stmts; }
public void AddSymbolInFunction(string id, SmclType type) { if (IsVisitingServer()) { Server s = (Server)VisitPartEnv.Mp; foreach (var group in s.Groups) { if (group.Id.Name == id) throw new TypeCheckingException("there's a group with the same id --> '" + id + "'"); } } else { Client c = (Client)VisitPartEnv.Mp; foreach (var tunnel in c.Tunnels) { if (tunnel.Typed.Id.Name == id) throw new TypeCheckingException("there's a tunnel with the same id --> '" + id + "'"); } } if (!VisitPartEnv.Functions.ContainsKey(VisitFunName)) throw new TypeCheckingException("typechecker logic fails in AddSymbolInFunction function."); if (VisitPartEnv.Functions[VisitFunName].SymbolTable.ContainsKey(id)) throw new TypeCheckingException("this id is already defined --> '" + id + "'"); VisitPartEnv.Functions[VisitFunName].SymbolTable.Add(id, type); }
public Typed(SmclType smclType, Id id) { SmclType = smclType; _id = id; }
private void MustBeSboolOrSubtype(SmclType t, string msg) { MustBe(t, BoolType, msg); }
private void MustBeSintOrSubtype(SmclType t, string msg) { MustBe(t, IntType, msg); }
private static void MustBe(SmclType t, SmclType mustBe, string msg) { if (!t.Equals(mustBe)) throw new TypeCheckingException(msg); }
private static SmclType ConvertToSecret(SmclType t) { var ttype = t.GetSecret(); if (ttype == null) return null; if (ttype == typeof(SintType)) { return SintType; } if (ttype == typeof(SboolType)) { return SboolType; } if (ttype == typeof(SclientType)) { return SclientType; } return null; }
private static SmclType ConvertToPublic(SmclType t) { var ttype = t.GetPublic(); if (ttype == null) return null; if (ttype == typeof(IntType)) { return IntType; } if (ttype == typeof(BoolType)) { return BoolType; } if (ttype == typeof(ClientType)) { return ClientType; } return null; }
public void CheckTunnelMethod(string id, SmclType expType) { if (!Tunnels.ContainsKey(id)) throw new TypeCheckingException(id + " isn't defined as tunnel."); if (!Tunnels[id].Equals(expType)) throw new TypeCheckingException( String.Format( "the tunnel {0} has type {1} but is invoked with a {2} expression.", id, Tunnels[id], expType ) ); }
public TunnelType(SmclType tunneled) : this() { Tunneled = tunneled; }