public void StopDefiningCtor(string name, ADType tydef) { //TODO add module name to ADT tydef.SetValCtor(_definingCtor.ValCtorNames, _definingCtor.ValCtorTys, _definingCtor.Kind); TypeCtorMap.Add(name, tydef); _definingCtor = null; _definingCtorEnv.Clear(); }
public void StartDefiningCtor(string name, List <string> paramLst, LexLocation lexLocation) { CheckTypeCtorNameEnv(name, lexLocation); if (TypeCtorMap.TryGetValue(name, out var ty)) { throw new ADTDuplicatedException(lexLocation, ty); } _definingCtor = TypeCtorSig.Create(this, name, paramLst, lexLocation); CheckTypeCtorKind(_definingCtor); }
private void CheckTypeCtorKind(TypeCtorSig sig) { //TODO _definingCtor.Name != Int , Double, String TypeExpr ctorKind = UType.Instance; for (var i = 0; i < _definingCtor.ParamList.Length; i++) { if (_definingCtorEnv.ContainsKey(_definingCtor.ParamList[i])) { throw new SemanticException($"duplicated parameter names of Type Constructor:{_definingCtor.ParamList[i]}", _definingCtor.Loc); } _definingCtorEnv.Add(_definingCtor.ParamList[i], UType.Instance); ctorKind = TyArr.Create(UType.Instance, ctorKind, this); } _definingCtorEnv.Add(_definingCtor.Name, ctorKind); _definingCtor.Kind = ctorKind; }