本文整理汇总了C#中ProtoCore类的典型用法代码示例。如果您正苦于以下问题:C# ProtoCore类的具体用法?C# ProtoCore怎么用?C# ProtoCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtoCore类属于命名空间,在下文中一共展示了ProtoCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConcatString
public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Core core)
{
var v1 = op1.IsString ? ArrayUtils.GetValues(op1, core) : new StackValue[] { op1 };
var v2 = op2.IsString ? ArrayUtils.GetValues(op2, core) : new StackValue[] { op2 };
StackValue tmp = core.Rmem.BuildArray(v1.Concat(v2).ToArray());
return StackValue.BuildString(tmp.opdata);
}
示例2: BuildAssocIdentifier
public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(ProtoLanguage.CompileStateTracker compileState, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
{
var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
ident.Name = ident.Value = name;
ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, false);
return ident;
}
示例3: BuildAssocIdentifier
public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(Core core, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
{
var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
ident.Name = ident.Value = name;
ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, 0);
return ident;
}
示例4: Compile
private bool Compile(string code, ProtoCore.Core core, ProtoCore.CompileTime.Context context)
{
bool buildSucceeded = false;
try
{
// No More HashAngleReplace for unified parser (Fuqiang)
//String strSource = ProtoCore.Utils.LexerUtils.HashAngleReplace(code);
//defining the global Assoc block that wraps the entire .ds source file
ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock();
globalBlock.Language = ProtoCore.Language.Associative;
globalBlock.Code = code;
//passing the global Assoc wrapper block to the compiler
ProtoCore.Language id = globalBlock.Language;
int blockId = Constants.kInvalidIndex;
core.Compilers[id].Compile(out blockId, null, globalBlock, context, EventSink);
core.BuildStatus.ReportBuildResult();
buildSucceeded = core.BuildStatus.BuildSucceeded;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return buildSucceeded;
}
示例5: ImperativeCodeGen
public ImperativeCodeGen(ProtoLanguage.CompileStateTracker compileState, ProtoCore.DSASM.CodeBlock parentBlock = null)
: base(compileState, parentBlock)
{
// dumpbytecode is optionally enabled
//
astNodes = new List<ImperativeNode>();
SetCompileOptions();
// Create a new symboltable for this block
// Set the new symbol table's parent
// Set the new table as a child of the parent table
codeBlock = new ProtoCore.DSASM.CodeBlock(
ProtoCore.DSASM.CodeBlockType.kLanguage,
ProtoCore.Language.kImperative,
compileState.CodeBlockIndex,
new ProtoCore.DSASM.SymbolTable("imperative lang block", compileState.RuntimeTableIndex),
new ProtoCore.DSASM.ProcedureTable(compileState.RuntimeTableIndex));
++compileState.CodeBlockIndex;
++compileState.RuntimeTableIndex;
compileState.CodeBlockList.Add(codeBlock);
if (null != parentBlock)
{
// This is a nested block
parentBlock.children.Add(codeBlock);
codeBlock.parent = parentBlock;
}
blockScope = 0;
}
示例6: ExecutionMirror
/// <summary>
/// Create a mirror for a given executive
/// </summary>
/// <param name="exec"></param>
public ExecutionMirror(ProtoCore.DSASM.Executive exec, ProtoCore.RuntimeCore coreObj)
{
Validity.Assert(exec != null, "Can't mirror a null executive");
runtimeCore = coreObj;
MirrorTarget = exec;
}
示例7: LoadAndExecute
public ExecutionMirror LoadAndExecute(string fileName, ProtoCore.Core core, bool isTest = true)
{
string codeContent = string.Empty;
try
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(fileName, Encoding.UTF8, true))
{
codeContent = reader.ReadToEnd();
}
}
catch (System.IO.IOException)
{
throw new FatalError("Cannot open file " + fileName);
}
//Start the timer
core.StartTimer();
core.CurrentDSFileName = ProtoCore.Utils.FileUtils.GetFullPathName(fileName);
core.Options.RootModulePathName = core.CurrentDSFileName;
Execute(codeContent, core);
if (!core.Options.CompileToLib && (null != core.CurrentExecutive))
return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
return null;
}
示例8: Compile
public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null)
{
Validity.Assert(langBlock != null);
blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
bool buildSucceeded = false;
bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock);
if (isLanguageSignValid)
{
try
{
ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, callContext, parentBlock);
codegen.context = callContext;
codegen.codeBlock.EventSink = sink;
blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode);
}
catch (ProtoCore.BuildHaltException)
{
}
buildSucceeded = core.BuildStatus.BuildSucceeded;
}
return buildSucceeded;
}
示例9: CoreCodeGen
public CoreCodeGen(ProtoLanguage.CompileStateTracker compileState, ProtoCore.DSASM.CodeBlock parentBlock = null)
{
Debug.Assert(compileState != null);
this.compileState = compileState;
argOffset = 0;
globalClassIndex = compileState.ClassIndex;
if (null == CoreCodeGen.CodeRangeTable)
CoreCodeGen.CodeRangeTable = new CodeRangeTable();
if (null == CoreCodeGen.IdentLocation)
CoreCodeGen.IdentLocation = new IdentLocationTable();
if (null == CoreCodeGen.ImportTable)
CoreCodeGen.ImportTable = new ImportTable();
context = new ProtoCore.CompileTime.Context();
targetLangBlock = ProtoCore.DSASM.Constants.kInvalidIndex;
enforceTypeCheck = true;
localProcedure = compileState.ProcNode;
globalProcIndex = null != localProcedure ? localProcedure.procId : ProtoCore.DSASM.Constants.kGlobalScope;
tryLevel = 0;
}
示例10: Compile
public override bool Compile(ProtoLanguage.CompileStateTracker compileState, out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null)
{
Debug.Assert(langBlock != null);
blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
bool buildSucceeded = false;
bool isLanguageSignValid = isLanguageSignValid = compileState.Langverify.Verify(langBlock);
if (isLanguageSignValid)
{
try
{
ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(compileState, parentBlock);
codegen.context = callContext;
codegen.codeBlock.EventSink = sink;
blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode);
}
catch (ProtoCore.BuildHaltException e)
{
#if DEBUG
//core.BuildStatus.LogSemanticError(e.errorMsg);
#endif
}
int errors = 0;
int warnings = 0;
buildSucceeded = compileState.BuildStatus.GetBuildResult(out errors, out warnings);
}
return buildSucceeded;
}
示例11: BinExprNode
public BinExprNode(ProtoCore.DSASM.Operator optr, Node leftNode, Node rightNode)
: base(leftNode.Name, leftNode.Guid)
{
this.Optr = optr;
this.left = leftNode;
this.right = rightNode;
}
示例12: Compile
public bool Compile(string code, ProtoCore.Core core, out int blockId)
{
bool buildSucceeded = false;
blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
try
{
// No More HashAngleReplace for unified parser (Fuqiang)
//String strSource = ProtoCore.Utils.LexerUtils.HashAngleReplace(code);
System.IO.MemoryStream sourceMemStream = new System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(code));
ProtoScript.GenerateScript gs = new ProtoScript.GenerateScript(core);
core.Script = gs.preParseFromStream(sourceMemStream);
foreach (ProtoCore.LanguageCodeBlock codeblock in core.Script.codeblockList)
{
ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context();
ProtoCore.Language id = codeblock.language;
core.Executives[id].Compile(out blockId, null, codeblock, context, EventSink);
}
core.BuildStatus.ReportBuildResult();
buildSucceeded = core.BuildStatus.BuildSucceeded;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return buildSucceeded;
}
示例13: Execute
private ExecutionMirror Execute(string code, ProtoCore.Core core, bool isTest = true)
{
int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
bool succeeded = Compile(code, core, out blockId);
if (succeeded)
{
core.GenerateExecutable();
core.Rmem.PushFrameForGlobals(core.GlobOffset);
core.RunningBlock = blockId;
Execute(core);
if (!isTest) { core.Heap.Free(); }
if (isTest && !core.Options.CompileToLib)
return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
else
return null;
}
//else
// throw new ProtoCore.Exceptions.CompileErrorsOccured();
//if (isTest && !core.Options.CompileToLib)
// return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
//else
return null;
}
示例14: RuntimeMirror
/// <summary>
/// This consutructor is for instantiating a Runtime mirror object where we already have the mirrorData
/// </summary>
/// <param name="mirrorData"></param>
/// <param name="core"></param>
public RuntimeMirror(MirrorData mirrorData, ProtoCore.Core core, ProtoCore.Core staticCore = null) : base(core, staticCore)
{
Validity.Assert(this.core != null);
TargetExecutive = core.CurrentExecutive.CurrentDSASMExec;
deprecateThisMirror = new DSASM.Mirror.ExecutionMirror(TargetExecutive, core);
this.mirrorData = mirrorData;
}
示例15: DebugRunner
public DebugRunner(ProtoCore.Core core)
{
this.core = core;
this.core.Options.IDEDebugMode = true;
RegisteredBreakpoints = new List<Breakpoint>();
executionsuspended = false;
}