public Interpreter() { mTypeCtxt = new TypeCtxtGlobal(); mTypeEnv = new TypeEnvGlobal(); mValueCtxt = new ValueCtxtGlobal(); mValueEnv = new ValueEnvGlobal(); }
public IKind Check(ITypeCtxt typeCtxt) { typeCtxt = typeCtxt.MakeChild(); typeCtxt.Add(mTypeVarName, mKind); IKind kind = mTypeExpr.Check(typeCtxt); return new KArrow(mKind, kind); }
public IKind Check(ITypeCtxt typeCtxt) { return new KArrow( new KArrow(mKind, KCType.Instance), KCType.Instance ); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { return mValueConst.ToType(); }
public IKind Check(ITypeCtxt typeCtxt) { foreach (ITypeExpr typeExpr in mMethodTypeExprs.Values) { typeExpr.Check(typeCtxt); } return KCType.Instance; }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { mTypeExpr.Check(typeCtxt); mTypeExpr.Eval(typeEnv); return TCUnit.Instance; }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IType type1 = mValueExpr1.Check(typeCtxt, typeEnv, valueCtxt); IType type2 = mValueExpr2.Check(typeCtxt, typeEnv, valueCtxt); return CheckApp(type1, type2); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IType type = mValueExpr.Check(typeCtxt, typeEnv, valueCtxt); valueCtxt.Add(mValueVarName, type); return type; }
public IKind Check(ITypeCtxt typeCtxt) { IKind result; if (!typeCtxt.TryGetValue(mTypeVarName, out result)) { throw new InvalidOperationException( string.Format("unknown type variable: {0}", mTypeVarName) ); } return result; }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IType type1 = mValueExpr.Check(typeCtxt, typeEnv, valueCtxt); IKind kind = mTypeExpr.Check(typeCtxt); IType type2 = mTypeExpr.Eval(typeEnv); return CheckApp(type1, kind, type2); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { Unique unique = new Unique(); typeCtxt = typeCtxt.MakeChild(); typeEnv = typeEnv.MakeChild(); typeCtxt.Add(mTypeVarName, mKind); typeEnv.Add(mTypeVarName, new TVar(unique)); IType type = mValueExpr.Check(typeCtxt, typeEnv, valueCtxt); return MakePolymorphicType(unique, mKind, type); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { var methodTypes = new Dictionary<string, IType>(); foreach (KeyValuePair<string, IValueExpr> kvp in mMethodValueExprs) { methodTypes.Add( kvp.Key, kvp.Value.Check(typeCtxt, typeEnv, valueCtxt) ); } return new TObj(methodTypes); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IType result; if (!valueCtxt.TryGetValue(mValueVarName, out result)) { throw new InvalidOperationException( string.Format("unknown variable: {0}", mValueVarName) ); } return result; }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IType type = mValueExpr.Check(typeCtxt, typeEnv, valueCtxt); if (!(type is TObj)) { throw new InvalidOperationException( string.Format( "{0} doesn't have an object type", mValueExpr.Show() ) ); } return ((TObj)type).GetMethodType(mMethodName); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { IKind kind = mTypeExpr.Check(typeCtxt); if (!(kind is IKindConst)) { throw new InvalidOperationException( string.Format( "{0} doesn't have a base kind", mTypeExpr.Show() ) ); } IType type1 = mTypeExpr.Eval(typeEnv); valueCtxt = valueCtxt.MakeChild(); valueCtxt.Add(mValueVarName, type1); IType type2 = mValueExpr.Check(typeCtxt, typeEnv, valueCtxt); return MakeFunctionType(type1, type2); }
public IType Check( ITypeCtxt typeCtxt, ITypeEnv typeEnv, IValueCtxt valueCtxt ) { mTypeExpr.Check(typeCtxt); IType rolledType = mTypeExpr.Eval(typeEnv); IType unrolledType = VEFold.Unroll(rolledType); IType valueExprType = mValueExpr.Check( typeCtxt, typeEnv, valueCtxt ); if (!valueExprType.Equals(rolledType)) { throw new InvalidOperationException( string.Format( "{0} cannot be unfolded with the type {1}", mValueExpr.Show(), mTypeExpr.Show() ) ); } return unrolledType; }
public IKind Check(ITypeCtxt typeCtxt) { IKind kind1 = mTypeExpr1.Check(typeCtxt); IKind kind2 = mTypeExpr2.Check(typeCtxt); return CheckApp(kind1, kind2); }
public IKind Check(ITypeCtxt typeCtxt) { IKind kind = mTypeExpr.Check(typeCtxt); typeCtxt.Add(mTypeVarName, kind); return kind; }
public TypeCtxtLocal(ITypeCtxt parent) { mDictionary = new Dictionary<string, IKind>(); mParent = parent; }