public ConvertionResult(string cAlgoCode, IEnumerable<ParsingError> parsingErrors, IEnumerable<CompilerError> compilerErrors, CodeBase codeBase) { CodeBase = codeBase; ParsingErrors = parsingErrors; CompilerErrors = compilerErrors; CAlgoCode = cAlgoCode; }
internal override CodeBase List(List visitedObject) { var visitor = this; var data = visitedObject.Data; var newList = new CodeBase[data.Length]; var index = data.Length - 1; var codeBase = data[index]; newList[index] = codeBase.Visit(visitor); return visitor.List(visitedObject, newList); }
protected IList<Hit> HitsFor(params string[] text) { List<string> unit = new List<string>(); AddPrefix(unit); unit.AddRange(text); AddSuffix(unit); string joinedText = String.Join(Environment.NewLine, unit.ToArray()); CodeBase codeBase = new CodeBase(CompilerDefines.CreateEmpty(), new MemoryFileLoader()); codeBase.AddFileExpectingSuccess("Foo.pas", joinedText); return CreateAction().Execute(codeBase); }
public static CodeBase Execute(CodeBaseOptions options, BackgroundWorker backgroundWorker) { CodeBase codeBase = new CodeBase(options.CreateCompilerDefines(), new FileLoader()); CodeBaseWorker worker = new CodeBaseWorker(codeBase, options, backgroundWorker); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { worker.ExecuteInternal(); } catch(CancelException) { } stopwatch.Stop(); codeBase.ParseDuration = stopwatch.Elapsed; return codeBase; }
private static void StartPkrChart() { string currentLogFile = null; currentLogFile = GetCurrentLogFileName(currentLogFile); if (String.IsNullOrEmpty(currentLogFile)) { Console.WriteLine("Log is not available"); return; } try { string codebaseDir = Path.GetDirectoryName(CodeBase.Get()); string exePath = Path.Combine(codebaseDir, "pkrchart.exe"); string cmdLine = "\"" + currentLogFile + "\""; log.InfoFormat("Starting: {0} {1}", exePath, cmdLine); Process.Start(exePath, cmdLine); } catch (Exception e) { Console.WriteLine(e.Message); } }
public CodeBase Analyze(MetricsCommandArguments details) { var command = collectionStepFactory.GetStep(details.RepositorySourceType); details.MetricsOutputFolder = fileSystem.MetricsOutputFolder; var metricsResults = command.Run(details); var codeBase = CodeBase.Empty(); foreach (var x in metricsResults) { var filename = x.MetricsFile; var cb = codebaseService.Get(fileSystem.OpenFileStream(filename), x.ParseType); codeBase.Enrich(new CodeGraph(cb.AllInstances)); } var codebase = analyzerFactory.For(details.RepositorySourceType).Analyze(codeBase.AllInstances); codebase.SourceType = details.RepositorySourceType; codebase.Name = details.ProjectName; return(codebase); }
public string AddCodeBase() { string Type = ""; switch (Request.Form["Type"]) { case "0": Type = "Tags"; break; } if (Type == "") { return("defeated"); } CodeBase codeBase = new CodeBase { Remark = Request.Form["Remark"], Type = Type }; Codebase_service.Add(codeBase); return("ok"); }
public void Test_Evaluator() { CompilerParameters cp = new CompilerParameters(); cp.GenerateExecutable = false; cp.GenerateInMemory = true; cp.ReferencedAssemblies.Add("system.dll"); cp.ReferencedAssemblies.Add(Path.GetFileName(CodeBase.Get(Assembly.GetExecutingAssembly()))); string code = "using System; using ai.lib.utils.nunit;"; code += "public class _Evaluator {\n"; code += " public object Evaluate(RuntimeCompile_Test param) {\n"; code += " return param.Field1*3;\n"; code += " }}"; Assembly asm = RuntimeCompile.Compile(code, cp); Object evaluator = asm.CreateInstance("_Evaluator"); MethodInfo mi = evaluator.GetType().GetMethod("Evaluate"); object result = mi.Invoke(evaluator, new object[] { this }); Assert.AreEqual(Field1 * 3, (int)result); code = "using System; using ai.lib.utils.nunit;"; code += "public class _Evaluator {\n"; code += " public object Evaluate(RuntimeCompile_Test param) {\n"; code += " return param.FieldArr1[2] + 5;\n"; code += " }}"; asm = RuntimeCompile.Compile(code, cp); evaluator = asm.CreateInstance("_Evaluator"); mi = evaluator.GetType().GetMethod("Evaluate"); result = mi.Invoke(evaluator, new object[] { this }); Assert.AreEqual(FieldArr1[2] + 5, (int)result); }
/// <summary> /// this will execute all DCBaseModel Items. /// </summary> /// <param name="isYesClasue">if is null parent is not a condition otherwise it is output of yes</param> private void ExecuteCodeModel(List <DCBaseModel> codeObjects, CodeBase codeBase, bool onlyCondition, string parentShapeID, ref bool result, bool?isYesClasue = false) { string currentShapeID = string.Empty; bool? nextIsYesClasue = null; foreach (DCBaseModel dcBase in codeObjects.Where(c => c.ParentShapeID == parentShapeID && (!isYesClasue.HasValue || (isYesClasue == true && c.IsOutputYes == true) || (isYesClasue == false && c.IsOutputYes == false)))) { currentShapeID = dcBase.ShapeID; if (dcBase is DCExpressionModel) { result = codeBase.ExecuteCode(dcBase.FuncName).ToBoolObj(); } else { if (dcBase is DCConditionModel) { if (onlyCondition) { result = dcBase.Execute(codeBase); } else { nextIsYesClasue = dcBase.Execute(codeBase); } } else { dcBase.Execute(codeBase); } } } if (!string.IsNullOrWhiteSpace(currentShapeID)) { this.ExecuteCodeModel(codeObjects, codeBase, onlyCondition, currentShapeID, ref result, nextIsYesClasue); } }
// ------------------------------------------------------------------- /// Determines if all producer are in the same execution context. bool AreAllInSameExecutionContext(out CodeBase code) { code = null; foreach (var e in myEnablePorts) { var producerPort = e.SegmentProducerPort; var producerParent = producerPort.ParentNode; var function = GetFunction(producerParent); if (function == null) { return(false); } var c = Context.GetCodeFor(function).Parent; if (code == null) { code = c; } else if (code != c) { return(false); } } return(true); }
public void SetUp() { _codeBase = new CodeBase(CompilerDefines.CreateEmpty(), new MemoryFileLoader()); }
void IVisitor.ThenElse(Size condSize, CodeBase thenCode, CodeBase elseCode) => NotImplementedMethod(condSize, thenCode, elseCode);
public HeroTreeVis() { CompilerParams.ReferencedAssemblies.Add(CodeBase.Get(Assembly.GetExecutingAssembly())); }
public void Setup() { RemoveFile(SampleProject); codebase = new CodeBase(CodeGraphFixture.MetropolisGraph); projectRepository = new ProjectRepository(); }
void IVisitor.List(CodeBase[] data) { foreach(var codeBase in data) SubVisit(codeBase); }
public void Create() { provider.Create(); provider.CodeBase.ReflectionEquals(CodeBase.Empty(), true); }
// =================================================================== // FIELDS // ------------------------------------------------------------------- // =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds a Function specific code context object. /// /// @param node VS objects associated with the function. /// @return The newly created code context. /// public EventHandlerDefinition(iCS_EditorObject node, CodeBase parent, AccessSpecifier accessType, ScopeSpecifier scopeType) : base(node, parent, accessType, scopeType) { CreateLocalVariables(); }
internal static string GenerateCSharpStatements(CodeBase codeBase) { var generator = new CSharpGenerator(codeBase.TemporarySize.SaveByteCount); try { codeBase.Visit(generator); } catch(UnexpectedContextReference e) { Tracer.AssertionFailed("", () => e.Message); } return generator.Data; }
void IVisitor.List(CodeBase[] data) { foreach(var codeBase in data) codeBase.Visit(this); }
void IVisitor.ThenElse(Size condSize, CodeBase thenCode, CodeBase elseCode) { AddCode("if({0})\n{{", PullBool(condSize.ByteCount)); Indent(); thenCode.Visit(this); Unindent(); AddCode("}}\nelse\n{{"); Indent(); elseCode.Visit(this); Unindent(); AddCode("}}"); }
void IVisitor.ThenElse(Size condSize, CodeBase thenCode, CodeBase elseCode) { var bitsConst = Pull(condSize).GetBitsConst(); SubVisit(bitsConst.IsZero ? elseCode : thenCode); }
public void Analyze(ProjectDetailsViewModel viewModel) { CodeBase.SourceType = viewModel.RepositorySourceType; CodeBase.Name = viewModel.ProjectName; CodeBase = analysisService.Analyze(BuildArguments(viewModel)); }
public RemoveLocalReferences(CodeBase body, CodeBase copier) : base(_nextObjectId++) { Body = body; Copier = copier; _referencesCache = new ValueCache<LocalReference[]>(GetReferencesForCache); _reducedBodyCache = new ValueCache<CodeBase>(GetReducedBodyForCache); }
public void Load(string fileName) { CodeBase = codebaseService.Load(fileName); }
CodeBase GetNewBody(CodeBase body) => _references.Any() ? (body.Visit(this) ?? body) : body;
public void Visit(CodeBase codeBase) { foreach (NamedContent<AstNode> node in codeBase.ParsedFiles) VisitSourceFile(node.FileName, node.Content); }
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds a parameter definition. /// /// @param port The VS port of the parameter. /// @param parent The parent code context. /// @return The newly created reference. /// public FunctionCallParameterDefinition(iCS_EditorObject port, CodeBase parent, Type neededType = null) : base(port, parent) { myType = neededType; }
public override int GetHashCode() { return(AssemblyName.GetHashCode() ^ ClassName.GetHashCode() ^ CodeBase.GetHashCode() ^ RuntimeVersion.GetHashCode()); }
// ------------------------------------------------------------------- public override void AddExecutable(CodeBase executableDefinition) { Debug.LogWarning("iCanScript: Trying to add a child executable definition to a function call definition."); }
protected override void OnInit(EventArgs e) { base.OnInit(e); EnsureChildControls(); if (CodeMirrorEnabled) { ClientDependencyLoader.Instance.RegisterDependency(0, "lib/CodeMirror/lib/codemirror.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/mode/" + CodeBase.ToString().ToLower() + "/" + CodeBase.ToString().ToLower() + ".js", "UmbracoRoot", ClientDependencyType.Javascript); if (CodeBase == EditorType.HtmlMixed) { ClientDependencyLoader.Instance.RegisterDependency(1, "lib/CodeMirror/mode/xml/xml.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(1, "lib/CodeMirror/mode/javascript/javascript.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(1, "lib/CodeMirror/mode/css/css.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(1, "lib/CodeMirror/mode/htmlmixed/htmlmixed.js", "UmbracoRoot", ClientDependencyType.Javascript); } ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/addon/search/search.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/addon/search/searchcursor.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/addon/dialog/dialog.js", "UmbracoRoot", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/addon/dialog/dialog.css", "UmbracoRoot", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency(2, "lib/CodeMirror/lib/codemirror.css", "UmbracoRoot", ClientDependencyType.Css); //ClientDependencyLoader.Instance.RegisterDependency(3, "CodeMirror/css/umbracoCustom.css", "UmbracoClient", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency(4, "CodeArea/styles.css", "UmbracoClient", ClientDependencyType.Css); } }
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds a function call code context. /// /// @param vsObj VS node associated with the function call. /// @param codeBlock The code block this assignment belongs to. /// @return The newly created function call definition. /// public FunctionCallDefinition(iCS_EditorObject vsObj, CodeBase parent) : base(vsObj, parent) { BuildParameterInformation(); BuildOutputParameters(); }
public void Send(CodeBase code) { var bytes = ProtocalData.Utilities.SerializaHelper.Serialize(code); webSocket.Send(bytes, 0, bytes.Length); }
public CodeView(CodeBase item, SourceView master) : base(master, "Code: " + item.NodeDump) { Client = item.CreateView(Master); Source = item.GetSource(); }
void IVisitor.List(CodeBase[] data) => NotImplementedMethod(data);
private CodeBaseWorker(CodeBase codeBase, CodeBaseOptions options, BackgroundWorker backgroundWorker) { _codeBase = codeBase; _options = options; _backgroundWorker = backgroundWorker; }
public Counter(CodeBase body) { body.Visit(this); }
public Reducer(LocalReference[] references, CodeBase body) { _references = references; _map = new FunctionCache<LocalReference, LocalReference>(GetReplacementsForCache); NewBody = GetNewBody(body); }
public ActionResult Login(FormCollection post) { if (ModelState.IsValid) { string account = string.Empty; //this.IsCaptchaValid("Captcha is not valid"); string password = string.Empty; CodeBase roleCode = new CodeBase(); roleCode.CodeTable = "AccountBase"; roleCode.CodeField = "AccountType"; List <CodeBase> roleCodeList = (List <CodeBase>) new MysqlDBA <CodeBase>(FunctionController.CONNSTR).getDataList(roleCode); Log.Info("Login-page started..."); try { account = post["AccountNo"]; password = post["AcntPwd"]; AccountBase accountBase = new AccountBase(); accountBase.AccountNo = account; MysqlDBA <AccountBase> accountBaseDB = new MysqlDBA <AccountBase>(ConfigurationManager.ConnectionStrings["MysqlConn"].ConnectionString); List <AccountBase> accountBasesList = (List <AccountBase>)accountBaseDB.getDataList(accountBase); if (accountBasesList.Count == 0) { TempData["action"] = "query"; TempData["error"] = "無此帳號:" + account; return(RedirectToAction("Index", "Login", null)); } bool verifyPasswd = false; //檢查使用者角色,有則帶到主頁面 bool userRole = false; accountBasesList.ForEach(o => { if (o.AccountNo == account) { if (o.AcntPwd == password) { verifyPasswd = true; Session["INSTNO"] = o.AcntTypeNo; Session["AccountNo"] = account; Session["AccountName"] = o.AcoountName; Session["AccountBase"] = o; roleCodeList.ForEach(t => { if (o.AccountType.Trim() == t.CodeValue.Trim()) { userRole = true; Session["userRole"] = o.AccountType; } }); } } }); if (!verifyPasswd) { TempData["action"] = "query"; TempData["error"] = "帳號:" + account + "密碼錯誤!"; return(RedirectToAction("Index", "Login", null)); } if (!userRole) { TempData["action"] = "query"; TempData["error"] = "帳號:" + account + "未設系統定角色!"; return(RedirectToAction("Index", "Login", null)); } } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "query"; TempData["error"] = ex + ex.StackTrace; return(RedirectToAction("Index", "Login", null)); } TempData["action"] = "query"; Session["AccountNo"] = account; return(RedirectToAction("Index", "Home", null)); } else { } if (Session["userRole"] != null && Session["userRole"].ToString() == "1") { TempData["action"] = "query"; } else { TempData["error"] = "Error: 連線失效或無效的驗證碼,請重新登入."; return(RedirectToAction("Index", "Login", null)); } if (Session["userRole"].ToString() == "2") { TempData["action"] = "committee"; } if (Session["userRole"].ToString() == "9") { TempData["action"] = "admin"; } TempData["error"] = "Error: 無效的驗證碼."; return(RedirectToAction("Index", "Login", null)); }
public IList<Hit> Execute(CodeBase codeBase) { ICodeBaseAction action = (ICodeBaseAction) Activator.CreateInstance(_type); return action.Execute(codeBase); }
public void Create() { CodeBase = CodeBase.Empty(); }
public void Save(CodeBase codeBase) { fileSystem.EnsureDirectoriesExist(fileSystem.AutoSaveFolder); projectRepository.Save(codeBase, Path.Combine(fileSystem.AutoSaveFolder, NextAutoSaveName)); }
public void Setup() { codeBase = CodeGraphFixture.Metropolis; }
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds an execution code block. /// /// @param vsObject The visual script objects associated with this code. /// @param codeBlock The code block this assignment belongs to. /// @return The newly created code context. /// public ExecutionBlockDefinition(iCS_EditorObject vsObject, CodeBase parent) : base(vsObject, parent) { }
public IList<Hit> Execute(CodeBase codeBase) { Visit(codeBase); return Hits; }
public TypeException(CodeBase actual, Arg visitedObject) { _actual = actual; _visitedObject = visitedObject; }
public void Save(CodeBase workspace, string fileName) { projectRepository.Save(workspace, fileName); }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { trvSummary.Nodes.Clear(); CodeBase codeBase = e.Result as CodeBase; if (codeBase != null) { _codeBase = codeBase; ShowParseResultsInTree(); } ActionResults actionResults = e.Result as ActionResults; if (actionResults != null) ShowHitsInTree(actionResults); ShowRunnerStatus(); }
public void SetUp() { _codeBase = new CodeBase(); _analyzer = new FileNeverReferencedAnalyzer(); }
private void btnParseAll_Click(object sender, EventArgs e) { _codeBase = null; CodeBaseOptions options = _codeBaseOptions.Clone(); RunBackground(delegate { return CodeBaseWorker.Execute(options, backgroundWorker1); }); }
private void Update() { //Get startpo each frame since it's the parent's startpo startpo = transform.parent.transform.position; //Move to the right if (!wait) { transform.position = new Vector2(transform.position.x + (speed * Time.deltaTime), transform.position.y); } //Destroy reader if over the last codebase if (transform.position.x > (startpo.x + posDifference)) { Stop(); } //Raycast and see collisions with block Vector2 orig = new Vector2(transform.position.x, transform.position.y); RaycastHit2D ray = Physics2D.Raycast(orig, Vector2.right, rayLength, codeBlockLayer); //Debug.DrawRay(orig, Vector2.right * rayLength, Color.green); if (ray) { CodeBase rayCodebase = ray.collider.gameObject.GetComponent <CodeBase>(); if (!rayCodebase.used && rayCodebase.HasSprite() && !playerObject.dead) { //Make player do actions corresponding the codebase if (rayCodebase.GetSprite() == codeBlockSprite[0]) { rayCodebase.Used(); playerObject.MoveForward(); } if (rayCodebase.GetSprite() == codeBlockSprite[1]) { rayCodebase.Used(); playerObject.RotateRight(); } if (rayCodebase.GetSprite() == codeBlockSprite[2]) { rayCodebase.Used(); playerObject.RotateLeft(); } if (rayCodebase.GetSprite() == codeBlockSprite[3]) { rayCodebase.Used(); playerObject.MoveBackward(); } if (rayCodebase.GetSprite() == codeBlockSprite[4]) { rayCodebase.Used(); playerObject.JumpForward(); } //React to loop blocks if (rayCodebase.blockId == 2) { rayCodebase.used = true; loopPositions[rayCodebase.currentSprite] = rayCodebase.transform.position; } if (rayCodebase.blockId == 1) { rayCodebase.used = true; //Loop cant work if you touch the start-one first if (loopPositions[rayCodebase.currentSprite].x != 0) { transform.position = loopPositions[rayCodebase.currentSprite]; } } } } //Stop if level completed if (GameManager.instance.levelCompleted) { Stop(); } }
CodeView CreateView(CodeBase target) => target == null ? null : new CodeView(target, this);
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds the property/field _SET_ code definition. /// /// @param vsObj VS node associated with the property/field _SET_. /// @return The newly created SET definition. /// public SetPropertyCallDefinition(iCS_EditorObject vsObj, CodeBase parent) : base(vsObj, parent) { }
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds an package code block. /// /// @param codeBlock The code block this assignment belongs to. /// @param enables The enable ports that affect this code block. /// @return The newly created code context. /// public PackageDefinition(iCS_EditorObject node, CodeBase parent, iCS_EditorObject[] enables) : base(node, parent) { }
// ------------------------------------------------------------------- /// Adds an execution child. /// /// @param child The execution child to add. /// public override void AddExecutable(CodeBase child) { myExecutionList.Add(child); child.Parent = this; }
internal CodeWithCleanup(CodeBase initialisation, CodeBase cleanupCode) : base(_nextObjectId++) { Initialisation = initialisation; CleanupCode = cleanupCode; }