public SimpleRecResult GenerateName(CompilerState State, Identifier Id, ref string Out) { if (Id is TypeOfFunction) { var FuncType = Id as TypeOfFunction; var FuncCh = FuncType.Children; var Rec = State.Language.Root.GetObject <CallingConventionRecognizer>(); var Mod = Rec.GetCallingConventionName(FuncType.CallConv); Out = Mod + " " + FuncCh[0].Name.ToString() + "("; for (var i = 1; i < FuncCh.Length; i++) { Out += State.GenerateName(FuncCh[i].TypeOfSelf); if (i < FuncCh.Length - 1) { Out += ", "; } } Out += ")"; return(SimpleRecResult.Succeeded); } return(SimpleRecResult.Unknown); }
public SimpleRecResult GenerateName(CompilerState State, Identifier Id, ref string Out) { if (Id is ReferenceType) { var RefType = Id as ReferenceType; var ChildName = " " + State.GenerateName(RefType.Children[0]); if (RefType.Mode == ReferenceMode.Unsafe) { Out = Operators[0] + ChildName; } else if (RefType.Mode == ReferenceMode.IdMustBeAssigned) { Out = Operators[1] + ChildName; } else if (RefType.Mode == ReferenceMode.IdGetsAssigned) { Out = Operators[2] + ChildName; } else { throw new ApplicationException(); } return(SimpleRecResult.Succeeded); } return(SimpleRecResult.Unknown); }
public string GetFuncTypeName(CompilerState State, TypeOfFunction FuncType) { var FuncCh = FuncType.Children; var Rec = State.Language.Root.GetObject <CallingConventionRecognizer>(); var Mod = Rec.GetCallingConventionName(FuncType.CallConv); var Out = Mod + " "; if (FuncCh.Length == 1) { Out += "void"; } else { for (var i = 1; i < FuncCh.Length; i++) { Out += State.GenerateName(FuncCh[i].TypeOfSelf); if (i < FuncCh.Length - 1) { Out += ", "; } } } Out += " -> "; var RetType = FuncCh[0]; if (RetType.RealId is TupleType) { var Tuple = RetType.RealId as TupleType; var Members = Tuple.StructuredScope.IdentifierList; for (var i = 0; i < Members.Count; i++) { Out += State.GenerateName(Members[i].TypeOfSelf); if (i < Members.Count - 1) { Out += ", "; } } } else { Out += State.GenerateName(RetType); } return(Out); }
public SimpleRecResult GenerateName(CompilerState State, Identifier Id, ref string Out) { if (Id is PointerType) { var PointerType = Id as PointerType; Out = State.GenerateName(PointerType.Children[0]) + "*"; return(SimpleRecResult.Succeeded); } return(SimpleRecResult.Unknown); }
public SimpleRecResult GenerateName(CompilerState State, Identifier Id, ref string Out) { if (Id is PointerAndLength) { var PAndL = Id as PointerAndLength; Out = State.GenerateName(PAndL.Child) + "[*]"; return(SimpleRecResult.Succeeded); } else if (Id is NonrefArrayType) { var Arr = Id as NonrefArrayType; Out = State.GenerateName(Arr.TypeOfValues) + "["; if (Arr.Lengths == null) { Out += "?"; } else { Out += string.Join(", ", Arr.Lengths); } Out += "]"; return(SimpleRecResult.Succeeded); } else if (Id is RefArrayType) { var Arr = Id as RefArrayType; Out = State.GenerateName(Arr.TypeOfValues) + "["; for (var i = 1; i < Arr.Dimensions; i++) { Out += ","; } Out += "]"; return(SimpleRecResult.Succeeded); } return(SimpleRecResult.Unknown); }
public SimpleRecResult GenerateName(CompilerState State, Identifier Id, ref string Out) { if (Id is TupleType) { var TupleType = Id as TupleType; var Members = TupleType.StructuredScope.IdentifierList; Out = "("; for (var i = 0; i < Members.Count; i++) { var Member = Members[i] as MemberVariable; if (TupleType.Named) { if (i == 0 || !(Members[i - 1] as MemberVariable).TypeOfSelf.IsEquivalent(Member.TypeOfSelf)) { Out += State.GenerateName(Member.TypeOfSelf) + " "; } Out += Member.Name.ToString(); } else { Out += State.GenerateName(Member.TypeOfSelf); } if (i < Members.Count - 1) { Out += ", "; } } Out += ")"; return(SimpleRecResult.Succeeded); } return(SimpleRecResult.Unknown); }