Пример #1
0
        public void CheckSemantics(Scope scope, Report report, FieldDecNode node)//se le pasa el nodo que estaba en la declaracion del record
        {
            if (id.name != node.id.name)
            {
                report.Add(Line, CharPositionInLine, string.Format("Record's field's names must be identical"));
                returnType = scope.FindType("error");
                return;
            }

            expr.CheckSemantics(scope, report);
            if (expr.returnType.isError)
            {
                returnType = scope.FindType("error");
                return;
            }

            TypeInfo info = scope.FindType(node.type.name);//Buscar el tipo de retorno que se designo en la declaracion del record

            if (info == null)
            {
                report.Add(node.Line, node.CharPositionInLine, string.Format("Cant find type {0}", node.type.name));
                returnType = scope.FindType("error");
                return;
            }

            if (!info.Alike(expr.returnType))
            {
                report.Add(Line, CharPositionInLine, string.Format("Cant assign {0} to {1}", info.name, expr.returnType.name));
                returnType = scope.FindType("error");
            }

            returnType = scope.FindType("void");
        }
Пример #2
0
        public void GenerateFunction(CodeGenerator cg)
        {
            var params_ = new List <Type>();

            foreach (var item in paramsTypes)
            {
                params_.Add(item.GetType(cg));
            }

            FunctionInfo info = funcScope.FindFunction(id.name);

            builder = cg.typeBuilder.DefineMethod(info.ConvertedName, System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.Static, CallingConventions.Standard, functionReturnType.GetType(cg), params_.ToArray());

            //buscar las variables para los parametros que recibira y crearlas si no existian
            for (int i = 0; i < paramList.parameters.Count; i++)
            {
                FieldDecNode currentField = paramList.parameters[i];
                VariableInfo current      = funcScope.ShortFindVariable(currentField.id.name);
                current.Create(cg);
            }
        }
Пример #3
0
 public FieldDecNode(FieldDecNode n) : base(n)
 {
 }