Exemplo n.º 1
0
        private ChangeSet Eval(ColaNode node)
        {
            var canonical = node.Script.ToCanonicalCola();
            var className = canonical.Substring(0, canonical.NthIndexOf(" ", 2)).Substring(4);

            // todo. regularly purge no more useful classes
            VM.Load(canonical);

            VM.Context["cc_values"] = _tempValues;
            VM.Context["cc_node"] = node;

            var changeset = new ChangeSet(() => _tempValues, v => { _tempValues = v; }).StartRecording();

            try
            {
                VM.CreateEntryPoint(className, "Main").RunTillEnd();
            }
            catch(ErroneousScriptException e)
            {
                // todo. a good idea would be to continue evaluation of everything that doesn't depend on this node
                var findings = InspectCompositionAndParameters();
                throw new FatalFindingsException(new Findings(
                    findings.Concat(new ScriptIsErroneousFactum(node, e).AsArray())));
            }

            return changeset.Capture();
        }
Exemplo n.º 2
0
 public ChangeSet Merge(ChangeSet nextVersion)
 {
     if (this.NewVersion == nextVersion.BaseLine)
     {
         var merged = new ChangeSet(Get, Set);
         merged.BaseLine = this.BaseLine;
         merged.NewVersion = nextVersion.NewVersion;
         merged.CaptureImpl();
         return merged;
     }
     else
     {
         throw new NotSupportedException(String.Format(
             "Cannot merge '{0}' with '{1}': incompatible revisions."));
     }
 }