public override void CheckSemantics(Scope scope, Report report) { TypeInfo info = scope.FindType(id.name); if (info == null) { report.Add(Line, CharPositionInLine, string.Format("Can't find type {0}", id.name)); returnType = scope.FindType("error"); return; } if (!info.isRecord)//El tipo del que se inteta crear el record debe haber sido declarado anteriormente como un record o un alias a un record { report.Add(Line, CharPositionInLine, string.Format("Cant create a record of {0}", info.name)); returnType = scope.FindType("error"); return; } RecordDecNode record = info.declaration.declaredType.declaration as RecordDecNode; if (fieldList != null) { fieldList.CheckSemantics(scope, report, record); if (fieldList.returnType.isError) { returnType = scope.FindType("error"); return; } } returnType = info.declaration.declaredType; }
public void CheckSemantics(Scope scope, Report report, RecordDecNode _record) { recordNode = _record; var fieldList = _record.paramsNode.parameters; for (int i = 0; i < fieldList.Count; i++) { if (fieldList[i].id.name == id.name) { fieldType = recordNode.infos[i]; return; } } returnType = scope.FindType("error"); }
public void CheckSemantics(Scope scope, Report report, RecordDecNode node) { Create(); if (fields.Count != node.paramsNode.ChildCount) {//La cantidad de parametros a inicializar tiene que ser igual que la cantidad de parametros declarados en el record report.Add(node.id.Line, node.id.CharPositionInLine, string.Format("Can't create record {0}, have {1} parameters, got {2}", node.id.name, node.paramsNode.ChildCount, fields.Count)); returnType = scope.FindType("error"); return; } for (int i = 0; i < fields.Count; i++) { fields[i].CheckSemantics(scope, report, node.paramsNode.parameters[i]); if (fields[i].returnType != null && fields[i].returnType.isError) { returnType = scope.FindType("error"); return; } } returnType = scope.FindType("void"); }
public RecordDecNode(RecordDecNode n) : base(n) { }