public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { foreach(var it in this.children) { it.writeOut(sw, cfg); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { sw.Write("(("); this.LIdent.writeOut(sw, cfg); sw.Write(" select 0) find ("); sw.Write('"' + this.RIdent.LastIdent.FullyQualifiedName + '"'); sw.Write(") != -1)"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.Write(tab + "throw "); foreach(var it in this.children) { it.writeOut(sw, cfg); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.Write(tab); foreach(var it in this.children) { it.writeOut(sw, cfg); sw.Write(' '); } sw.Write("breakOut \"" + Wrapper.Compiler.ScopeNames.function + "\""); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.Write(tab); this.Name.writeOut(sw, cfg); if (!this.Name.IsSimpleIdentifier && this.Name.ReferencedType.IsObject && !(this.Name.ReferencedType.ident.ReferencedObject is Native)) sw.Write(" set [0, "); else sw.Write(" = "); this.assign.writeOut(sw, cfg); if (!this.Name.IsSimpleIdentifier && this.Name.ReferencedType.IsObject && !(this.Name.ReferencedType.ident.ReferencedObject is Native)) sw.Write("]"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { //ToDo: Fix the wrong private of the forArg1 variable from inside of the loop to parent codeblock string tab = new string('\t', this.Parent.getAllParentsOf<Interfaces.iCodeBlock>().Count); this.forArg1.writeOut(sw, cfg); sw.WriteLine(";"); sw.Write(tab + "while {"); this.forArg2.writeOut(sw, cfg); sw.WriteLine("} do"); sw.WriteLine(tab + "{"); var varList = this.getAllChildrenOf<Variable>(); if (varList.Count > 0) { if (varList.Count == 1) sw.Write(tab + '\t' + "private "); else sw.Write(tab + '\t' + "private ["); for (int i = 0; i < varList.Count; i++) { var it = varList[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (varList.Count > 1) sw.Write("]"); sw.WriteLine(";"); } this.forArg3.writeOut(sw, cfg); sw.WriteLine(";"); foreach (var it in this.CodeInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.Parent.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.Write(tab + "switch "); this.expression.writeOut(sw, cfg); sw.WriteLine(" do"); sw.WriteLine(tab + "{"); foreach (var it in this.CodeInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); }
public override void writeOut(StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = this.Parent is Interfaces.iCodeBlock ? new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count) : ""; var lArgs = this.LArgs; var rArgs = this.RArgs; sw.Write(tab); if (lArgs.Count > 0) { if (lArgs.Count == 1) { lArgs[0].writeOut(sw, cfg); sw.Write(" "); } else { sw.Write("["); int index = 0; foreach (var it in lArgs) { if (index > 0) sw.WriteLine(","); index++; it.writeOut(sw, cfg); } sw.Write("] "); } } sw.Write(this.Name.OriginalValue); if (rArgs.Count > 0) { if (rArgs.Count == 1) { sw.Write(" "); rArgs[0].writeOut(sw, cfg); } else { sw.Write(" ["); int index = 0; foreach (var it in rArgs) { if (index > 0) sw.WriteLine(","); index++; it.writeOut(sw, cfg); } sw.Write("]"); } } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string variableName = this.Name.WriteOutValue; if(this.ReferencedObject is Interfaces.iFunction) { Interfaces.iFunction fnc = (Interfaces.iFunction)this.ReferencedObject; bool flag = false; if (fnc is NativeInstruction) { var nIns = (NativeInstruction)fnc; List<string> stringList = new List<string>(); stringList.Add(variableName); foreach (var it in this.children) { using (MemoryStream memStream = new MemoryStream()) { StreamWriter memStreamWriter = new StreamWriter(memStream); it.writeOut(memStreamWriter, cfg); memStreamWriter.Flush(); memStream.Seek(0, SeekOrigin.Begin); stringList.Add(new StreamReader(memStream).ReadToEnd()); } } sw.Write(nIns.getCode(stringList.ToArray())); } else { if (fnc.FunctionEncapsulation == Encapsulation.Static || fnc.IsConstructor) { sw.Write('['); } else { sw.Write('[' + variableName); flag = true; } foreach (var it in this.children) { if (flag) sw.Write(", "); else flag = true; it.writeOut(sw, cfg); } if (fnc is Function) { if (fnc.FunctionEncapsulation == Encapsulation.Static || fnc.IsConstructor) { sw.Write(']' + " call " + ((Function)fnc).SqfVariableName); } else { sw.Write(']' + " call (" + '(' + variableName + ')' + ((Function)fnc).SqfVariableName + ')'); } } else { throw new Exception(); } } } else { throw new Exception(); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.Parent.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.Write(tab + "if("); this.expression.writeOut(sw, cfg); sw.WriteLine(") then"); sw.WriteLine(tab + "{"); var varListFirstScope = this.getAllChildrenOf<Variable>(false, null, -1, 1); if (varListFirstScope.Count > 0) { if (varListFirstScope.Count == 1) sw.Write("private "); else sw.Write("private ["); for (int i = 0; i < varListFirstScope.Count; i++) { var it = varListFirstScope[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (varListFirstScope.Count > 1) sw.Write("]"); sw.WriteLine(";"); } foreach (var it in this.IfInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); if (this.ElseInstructions.Count > 0) { sw.WriteLine("\n" + tab + "else"); sw.WriteLine(tab + "{"); var varListSecondScope = this.getAllChildrenOf<Variable>(false, null, -1, 2); if (varListSecondScope.Count > 0) { if (varListSecondScope.Count == 1) sw.Write("private "); else sw.Write("private ["); for (int i = 0; i < varListSecondScope.Count; i++) { var it = varListSecondScope[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (varListSecondScope.Count > 1) sw.Write("]"); sw.WriteLine(";"); } foreach (var it in this.ElseInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { if(this.Parent is Ident) { var parentIdent = (Ident)this.Parent; if(parentIdent.ReferencedObject is Variable) { var variable = (Variable)parentIdent.ReferencedObject; bool printSelect = true; if(variable.ReferencedType.IsObject) { if (variable.ReferencedType.ident.ReferencedObject is Interfaces.iClass) { var c = (Interfaces.iClass)variable.ReferencedType.ident.ReferencedObject; var fnc = c.getOperatorFunction(OverridableOperator.ArrayAccess); if (fnc != null) { printSelect = false; string variableName = ((Ident)this.Parent).WriteOutValue; #region Copied from FunctionCall bool flag = false; if (fnc is NativeInstruction) { var nIns = (NativeInstruction)fnc; List<string> stringList = new List<string>(); stringList.Add(variableName); foreach (var it in this.children) { using (MemoryStream memStream = new MemoryStream()) { StreamWriter memStreamWriter = new StreamWriter(memStream); it.writeOut(memStreamWriter, cfg); memStreamWriter.Flush(); memStream.Seek(0, SeekOrigin.Begin); stringList.Add(new StreamReader(memStream).ReadToEnd()); } } sw.Write(nIns.getCode(stringList.ToArray())); } else { if (fnc.FunctionEncapsulation == Encapsulation.Static || fnc.IsConstructor) { sw.Write('['); } else { sw.Write('[' + variableName); flag = true; } foreach (var it in this.children) { if (flag) sw.Write(", "); else flag = true; it.writeOut(sw, cfg); } if (fnc is Function) { if (fnc.FunctionEncapsulation == Encapsulation.Static || fnc.IsConstructor) { sw.Write(']' + " call " + ((Function)fnc).SqfVariableName); } else { sw.Write(']' + " call " + '(' + variableName + ')' + ((Function)fnc).SqfVariableName); } } else { throw new Exception(); } } #endregion } } } if (printSelect) { //if(((Ident)this.Parent).HasCallWrapper) //{ sw.Write(((Ident)this.Parent).WriteOutValue); //} sw.Write(" select "); foreach(var it in this.children) { it.writeOut(sw, cfg); } } } } else { throw new Exception(); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.Parent.getAllParentsOf<Interfaces.iCodeBlock>().Count); var caseList = this.Cases; if (caseList.Count == 0) { sw.WriteLine(tab + "default {"); } else { foreach (var it in caseList) { sw.Write(tab + "case "); it.writeOut(sw, cfg); sw.Write(":"); } sw.WriteLine("{"); } var lastInstruction = CodeInstructions.Last(); foreach(var it in this.CodeInstructions) { if (it == lastInstruction) continue; it.writeOut(sw, cfg); sw.WriteLine(";"); } if (!(lastInstruction is Break)) { lastInstruction.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { int index; string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); if (this.encapsulation == Encapsulation.Static || this.IsConstructor) { var fqn = this.Name.FullyQualifiedName; var filePath = Wrapper.Compiler.ProjectFile.OutputFolder + fqn.Replace("::", "\\"); var fileFolderPath = filePath.Substring(0, filePath.LastIndexOf('\\')); if (!Directory.Exists(fileFolderPath)) Directory.CreateDirectory(fileFolderPath); sw = new System.IO.StreamWriter(filePath + ".sqf"); fqn = fqn.Replace("::", "_"); int lIndex = fqn.LastIndexOf('_'); string lPath; string rPath; if (lIndex <= 0) { lPath = "UNCATEGORIZED"; rPath = fqn; Logger.Instance.log(Logger.LogLevel.WARNING, "Function '" + this.Name.FullyQualifiedName + "' at line " + this.Name.Line + " has no namespace"); } else { lPath = fqn.Substring(0, lIndex); rPath = fqn.Substring(lIndex + 1); } cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "file", '"' + filePath.Substring(Wrapper.Compiler.ProjectFile.OutputFolder.Length) + ".sqf" + '"'); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "preInit", this.Name.OriginalValue == "preInit" ? "1" : "0"); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "postInit", this.Name.OriginalValue == "postInit" ? "1" : "0"); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "preStart", this.Name.OriginalValue == "preStart" ? "1" : "0"); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "recompile", "0"); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "ext", '"' + ".sqf" + '"'); cfg.setValue(lPath + '/' + "All" + '/' + rPath + '/' + "headerType", "-1"); } sw.WriteLine(tab + "scopeName \"" + Wrapper.Compiler.ScopeNames.function + "\";"); var argList = this.ArgListObjects; if (argList.Count > 0) { sw.Write(tab + "params ["); bool printComma = false; if (this.encapsulation != Encapsulation.Static && !this.IsConstructor) { sw.Write('"' + Wrapper.Compiler.thisVariableName + '"'); printComma = true; } foreach(var it in argList) { if (printComma) sw.Write(", "); if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } sw.WriteLine("];"); } var localVarList = this.getAllChildrenOf<Variable>(false, null, -1, 1); if (localVarList.Count > 0) { if (localVarList.Count == 1) sw.Write(tab + "private "); else sw.Write(tab + "private ["); for (int i = 0; i < localVarList.Count; i++) { var it = localVarList[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (localVarList.Count > 1) sw.Write("]"); sw.WriteLine(";"); } if (this.IsConstructor) { ///////////////////////////////// // OBJECT CONSTRUCTOR PRINTING // ///////////////////////////////// var classObject = this.getFirstOf<oosClass>(); var varList = classObject.AllVariables; var fncList = classObject.AllFunctions; if (varList.Count > 0 || fncList.Count > 0) { sw.Write(tab + "private ["); index = 0; foreach (var it in varList) { if (index > 0) sw.Write(", "); sw.Write("\"" + Wrapper.Compiler.thisVariableName + "var" + it.Name.OriginalValue.Replace("::", "_") + "\""); index++; } foreach (var it in fncList) { if (((Function)it).IsConstructor) continue; if (index > 0) sw.Write(","); sw.Write("\"" + Wrapper.Compiler.thisVariableName + "fnc" + it.Name.OriginalValue.Replace("::", "_") + "\""); index++; } sw.WriteLine("];"); } foreach (var it in varList) { sw.Write(Wrapper.Compiler.thisVariableName + "var" + it.Name.OriginalValue.Replace("::", "_") + " = ["); var val = it.Value; if (val == null) sw.Write("nil"); else val.writeOut(sw, cfg); sw.WriteLine("];"); } foreach (var it in fncList) { if (((Function)it).IsConstructor) continue; sw.WriteLine(Wrapper.Compiler.thisVariableName + "fnc" + it.Name.OriginalValue.Replace("::", "_") + " = {"); it.writeOut(sw, cfg); sw.WriteLine("};"); } sw.Write(tab + Wrapper.Compiler.thisVariableName + " = ["); //Write out parents info var classIdents = classObject.ParentClassesIdents; classIdents.Add(classObject.Name); sw.Write("["); index = 0; foreach (var it in classIdents) { if (index > 0) sw.Write(", "); if (it is Ident) { index++; sw.Write('"' + ((Ident)it).FullyQualifiedName + '"'); } else { throw new Exception("please report to developer, unknown exception happened in function object creation"); } } sw.Write("],["); index = 0; foreach (var it in classIdents) { if (index > 0) sw.Write(","); if (it is Ident) { var refObj = ((Ident)it).ReferencedObject; if (refObj is oosClass) { index++; var cObj = (oosClass)refObj; int index2 = 0; //LookupRegister sw.Write("[["); foreach (var child in cObj.children) { if (index2 > 0) sw.Write(", "); if (child is Function) { if (((Function)child).IsClassFunction && !((Function)child).IsConstructor) sw.Write('"' + ((Function)child).Name.FullyQualifiedName + '"'); else sw.Write("nil"); } else if (child is VirtualFunction) { sw.Write('"' + ((VirtualFunction)child).Name.FullyQualifiedName + '"'); } else if (child is Variable) { if (((Variable)child).IsClassVariable) sw.Write('"' + ((Variable)child).Name.FullyQualifiedName + '"'); else sw.Write("nil"); } else { sw.Write("nil"); } index2++; } sw.Write("], ["); index2 = 0; foreach (var child in cObj.children) { if (index2 > 0) sw.Write(", "); if (child is Function) { if (((Function)child).IsClassFunction && !((Function)child).IsConstructor) sw.Write(Wrapper.Compiler.thisVariableName + "fnc" + ((Function)child).Name.OriginalValue.Replace("::", "_")); else sw.Write("nil"); } else if (child is VirtualFunction) { sw.Write(Wrapper.Compiler.thisVariableName + "var" + ((VirtualFunction)child).Name.OriginalValue.Replace("::", "_")); } else if (child is Variable) { if (((Variable)child).IsClassVariable) sw.Write(Wrapper.Compiler.thisVariableName + "var" + ((Variable)child).Name.OriginalValue.Replace("::", "_")); else sw.Write("nil"); } else { sw.Write("nil"); } index2++; } sw.Write("], ["); sw.Write('"' + ((Ident)it).FullyQualifiedName + '"'); sw.Write("]]"); } else if (refObj is oosInterface) { index++; sw.Write("nil"); } else { throw new Exception("please report to developer, unknown exception happened in function object creation cast refObj"); } } else { throw new Exception("Function has Encapsulation.NA on encapsulation field, please report to developer"); } } sw.Write("], "); //Current active class sw.Write("nil, "); //Reserved for future meta informations sw.Write("[]"); sw.WriteLine("];"); //ToDo: add baseconstructor calls sw.WriteLine("//Actual constructor starts here, we just printed the object till here :)"); } foreach (var it in this.CodeInstructions) { if (it is Ident) sw.Write(tab); it.writeOut(sw, cfg); sw.WriteLine(";"); } if (this.IsConstructor) { sw.Write(tab + Wrapper.Compiler.thisVariableName); } if (this.encapsulation == Encapsulation.Static || this.IsConstructor) { sw.Flush(); sw.Close(); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { if (this.Parent is Ident || this.Parent is AssignContainer) { Ident parent = this.Parent is AssignContainer ? ((AssignContainer)this.Parent).Name.NextWorkerIdent : (Ident)this.Parent; string varName = '(' + parent.WriteOutValue + ')'; switch (this.Operation) { case AssignmentCharacters.PlusOne: sw.Write(varName + " + 1"); break; case AssignmentCharacters.MinusOne: sw.Write(varName + " - 1"); break; case AssignmentCharacters.AdditionAssign: sw.Write(varName + " + ("); foreach (var it in this.children) { it.writeOut(sw, cfg); } sw.Write(")"); break; case AssignmentCharacters.SubstractionAssign: sw.Write(varName + " - ("); foreach (var it in this.children) { it.writeOut(sw, cfg); } sw.Write(")"); break; case AssignmentCharacters.MultiplicationAssign: sw.Write(varName + " * ("); foreach (var it in this.children) { it.writeOut(sw, cfg); } sw.Write(")"); break; case AssignmentCharacters.DivisionAssign: sw.Write(varName + " / ("); foreach (var it in this.children) { it.writeOut(sw, cfg); } sw.Write(")"); break; default: foreach (var it in this.children) { it.writeOut(sw, cfg); } break; } } else if (this.Parent is Variable) { foreach(var it in this.children) { it.writeOut(sw, cfg); } } else { throw new NotImplementedException(); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.Parent.getAllParentsOf<Interfaces.iCodeBlock>().Count); sw.WriteLine(tab + "try"); sw.WriteLine(tab + "{"); var varListTry = this.getAllChildrenOf<Variable>(false, null, -1, 1); if (varListTry.Count > 0) { if (varListTry.Count == 1) sw.Write("private "); else sw.Write("private ["); for (int i = 0; i < varListTry.Count; i++) { var it = varListTry[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (varListTry.Count > 1) sw.Write("]"); sw.WriteLine(";"); } foreach(var it in this.TryInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.WriteLine(tab + "}"); sw.WriteLine(tab + "catch"); sw.WriteLine(tab + "{"); var varListCatch = this.getAllChildrenOf<Variable>(false, null, -1, 2); if (varListCatch.Count > 0) { if (varListCatch.Count == 1) sw.Write("private "); else sw.Write("private ["); for (int i = 0; i < varListCatch.Count; i++) { var it = varListCatch[i]; if (i != 0) { sw.Write(", "); } if (it is Variable) { sw.Write('"' + ((Variable)it).SqfVariableName + '"'); } else { throw new Exception(); } } if (varListCatch.Count > 1) sw.Write("]"); sw.WriteLine(";"); } this.variable.writeOut(sw, cfg); sw.WriteLine(" = _exception;"); foreach (var it in this.CatchInstructions) { it.writeOut(sw, cfg); sw.WriteLine(";"); } sw.Write(tab + "}"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { bool doBrackets = this.negate || this.rExpression != null; if (this.negate) sw.Write('!'); if (doBrackets) sw.Write('('); this.lExpression.writeOut(sw, cfg); if(this.rExpression != null) { sw.Write(") " + this.expOperator + " ("); this.rExpression.writeOut(sw, cfg); } if (doBrackets) sw.Write(')'); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { bool assignToTmp = this.HasCallWrapper; bool callWrapper = !(this.Parent is Ident) && assignToTmp; if (callWrapper) { sw.Write("[] call {private \"_tmp\"; "); if (this.ReferencedObject is Variable) { sw.Write("_tmp = " + ((Variable)this.ReferencedObject).SqfVariableName + ';'); } else { throw new Exception(); } } if (this.IsSimpleIdentifier && this.children.Count == 0) { if (this.ReferencedObject is Variable) { Variable variable = (Variable)this.ReferencedObject; sw.Write(variable.SqfVariableName); } else { throw new Exception(); } } else if (this.children.Count == 0) { sw.Write(this.WriteOutValue); } else { foreach (var it in this.children) { if (it is Ident) continue; if (assignToTmp) sw.Write(" _tmp = "); it.writeOut(sw, cfg); if (assignToTmp) sw.Write(';'); } foreach (var it in this.children) { if (it is Ident) it.writeOut(sw, cfg); } } if (callWrapper) sw.Write(" _tmp}"); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); var breakable = this.getFirstOf<Interfaces.iBreakable>(); sw.Write(tab + "breakOut \"" + breakable.BreakScope + "\""); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { if (sw == null) return; string tab = new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count); var assignList = this.getAllChildrenOf<VariableAssignment>(); sw.Write(tab + this.SqfVariableName); if (assignList.Count > 0) { sw.Write(" = "); assignList[0].writeOut(sw, cfg); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { foreach (var it in ClassContent) { if ((it is Interfaces.iFunction && ((Interfaces.iFunction)it).FunctionEncapsulation != Encapsulation.Static) && !(it is Function && ((Function)it).IsConstructor)) continue; if(it is Variable) continue; it.writeOut(sw, cfg); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { sw.Write(this.value); }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { //ToDo: do the actual casting stuff string tab = this.Parent is Interfaces.iCodeBlock ? new string('\t', this.getAllParentsOf<Interfaces.iCodeBlock>().Count) : ""; if (this.isStaticCast) { if (this.children.Count != 1 || !(this.children[0] is Ident)) throw new Exception(); Ident ident = (Ident)this.children[0]; switch (ident.ReferencedType.varType) { case VarType.ObjectStrict: { sw.Write(tab + "[] call {"); sw.Write("("); ident.writeOut(sw, cfg); sw.Write(") set [2, "); var result = HelperClasses.NamespaceResolver.getClassReferenceOfFQN(ident.ReferencedType.ident.LastIdent); if (result != null) { var index = result is oosClass ? ((oosClass)result).getClassIndex(this.varType.ident) : -1; if (index == -1) throw new Exception(); ident.writeOut(sw, cfg); sw.Write(" select 1 select " + index + "]; "); ident.writeOut(sw, cfg); } else { throw new Exception(); } sw.Write("}"); } break; case VarType.Bool: switch(this.ReferencedType.varType) { case VarType.Scalar: sw.Write("parseNumber "); ident.writeOut(sw, cfg); break; case VarType.String: sw.Write("str "); ident.writeOut(sw, cfg); break; default: ident.writeOut(sw, cfg); break; } break; case VarType.Scalar: switch (this.ReferencedType.varType) { case VarType.Bool: sw.Write("if("); ident.writeOut(sw, cfg); sw.Write(" > 0) then {true} else {false}"); break; case VarType.String: sw.Write("str "); ident.writeOut(sw, cfg); break; default: ident.writeOut(sw, cfg); break; } break; case VarType.String: switch (this.ReferencedType.varType) { case VarType.Bool: sw.Write("if("); ident.writeOut(sw, cfg); sw.Write(" == \"true\") then {true} else {false}"); break; case VarType.Scalar: sw.Write("parseNumber "); ident.writeOut(sw, cfg); break; default: ident.writeOut(sw, cfg); break; } break; default: throw new Exception(); } } else { sw.Write(tab + "[] call {"); if (this.children.Count != 1 || !(this.children[0] is Ident)) throw new Exception(); Ident ident = (Ident)this.children[0]; switch (ident.ReferencedType.varType) { case VarType.Object: { sw.WriteLine("private \"_index\"; "); sw.Write(tab + "_index = ("); ident.writeOut(sw, cfg); sw.WriteLine(") select 0 find \"" + this.varType.ident.FullyQualifiedName + "\"; "); sw.WriteLine(tab + "if (_index == -1) then { throw \"InvalidCastException\"; }; "); sw.Write(tab + '('); ident.writeOut(sw, cfg); sw.Write(") set [2, "); var result = HelperClasses.NamespaceResolver.getClassReferenceOfFQN(ident.ReferencedType.ident.LastIdent); if (result == null) throw new Exception(); var index = result is oosClass ? ((oosClass)result).getClassIndex(this.varType.ident) : -1; if (index == -1) throw new Exception(); ident.writeOut(sw, cfg); sw.Write(" select 1 select _index];"); ident.writeOut(sw, cfg); } break; case VarType.Bool: //ToDo: make an actual cast instead of just rewriting the output type during compile time ident.writeOut(sw, cfg); break; case VarType.BoolArray: //ToDo: make an actual cast instead of just rewriting the output type during compile time ident.writeOut(sw, cfg); break; case VarType.Scalar: //ToDo: make an actual cast instead of just rewriting the output type during compile time ident.writeOut(sw, cfg); break; case VarType.ScalarArray: //ToDo: make an actual cast instead of just rewriting the output type during compile time ident.writeOut(sw, cfg); break; case VarType.String: sw.Write("str "); ident.writeOut(sw, cfg); break; case VarType.StringArray: //ToDo: make an actual cast instead of just rewriting the output type during compile time ident.writeOut(sw, cfg); break; default: throw new Exception(); } sw.Write("}"); } }
public override void writeOut(System.IO.StreamWriter sw, SqfConfigObjects.SqfConfigFile cfg) { sw.Write("["); bool flag = false; foreach (var it in this.children) { if (flag) sw.Write(", "); else flag = true; it.writeOut(sw, cfg); } sw.Write("]"); }