本文整理汇总了C#中SymbolTable类的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable类的具体用法?C# SymbolTable怎么用?C# SymbolTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SymbolTable类属于命名空间,在下文中一共展示了SymbolTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(SymbolTable symbols, TextWriter tw, object item)
{
foreach (var child in Children)
{
child.Render(symbols, tw, item);
}
}
示例2: ProcessExpression
private bool ProcessExpression(SymbolTable symbolTable)
{
// TODO: If there are performance problems, we could find a faster way to detect expressions than doing a full parse
var tokenSequence = new TokenSequence(XValue);
if (tokenSequence.RequiresProcessing)
{
if (tokenSequence.RequiresTemplateArguments)
{
var templateInstance = TemplateInstance;
if (templateInstance == null || templateInstance.Template == null)
{
return false;
}
XValue = tokenSequence.Process(symbolTable, templateInstance.ArgumentDictionary);
}
else
{
XValue = tokenSequence.Process(symbolTable, null);
}
}
return true;
}
示例3: LoadLocalAddress
internal LoadLocalAddress(SymbolTable symbols, MethodDefinition method, Instruction untyped, int index) : base(untyped, index)
{
switch (untyped.OpCode.Code)
{
case Code.Ldloca_S:
case Code.Ldloca:
VariableDefinition param = untyped.Operand as VariableDefinition;
if (param != null)
{
Variable = param.Index;
Type = param.VariableType;
}
else
{
Variable = (int) untyped.Operand;
Type = method.Body.Variables[Variable].VariableType;
}
Name = symbols.LocalName(method, untyped, Variable);
break;
default:
DBC.Fail(untyped.OpCode.Code + " is not a valid LoadLocalAddress");
break;
}
RealName = symbols.HaveLocalNames(method);
}
示例4: RuleBuilder
/// <summary>
/// Constructs an empty rule builder.
/// </summary>
public RuleBuilder()
{
var rootScope = new SymbolTable();
_dependencyBuilder = new DependencyGroupBuilder(rootScope);
_groupBuilder = new GroupBuilder(rootScope, GroupType.And);
_actionGroupBuilder = new ActionGroupBuilder(rootScope);
}
示例5: Insert_Lookup_WriteTable_SymbolTableTest
public void Insert_Lookup_WriteTable_SymbolTableTest()
{
var count = 0;
var symTable = new SymbolTable();
symTable.Printer = (val) => { count++; };
symTable.Insert(Token.CreateToken("x", 0), 0);
symTable.Insert(Token.CreateToken("y", 0), 0);
symTable.Insert(Token.CreateToken("z", 0), 0);
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.Insert(Token.CreateToken("a", 0), 1);
symTable.Insert(Token.CreateToken("x", 0), 1);
symTable.Insert(Token.CreateToken("y", 0), 1);
symTable.Insert(Token.CreateToken("z", 0), 1);
symTable.Lookup("a").Content = CreateVariableContent();
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.WriteTable(0);
Assert.AreEqual(3, count);
count = 0;
symTable.WriteTable(1);
Assert.AreEqual(4, count);
count = 0;
symTable.WriteTable(2);
Assert.AreEqual(0, count);
}
示例6: NameExpression
public NameExpression(
IExpression identifier,
SymbolTable<string, IValue> symbolTable)
{
_identifier = identifier;
_symbolTable = symbolTable;
}
示例7: AddValue_Correct_Test
public void AddValue_Correct_Test()
{
symbolTable = new SymbolTable();
symbolTable.AddValue(id, new Bool(false));
Assert.IsNotNull(symbolTable.GetValue(id));
}
示例8: Init
public bool Init(ErrorHandling errorContext, SymbolTable symtable)
{
_runtimeBinderSymbolTable = symtable;
Debug.Assert(_pBSymmgr != null);
#if !CSEE
Debug.Assert(_predefSyms == null);
#else // CSEE
Debug.Assert(predefSyms == null || aidMsCorLib != KAID.kaidNil);
#endif // CSEE
if (_aidMsCorLib == KAID.kaidNil)
{
// If we haven't found mscorlib yet, first look for System.Object. Then use its assembly as
// the location for all other pre-defined types.
AggregateSymbol aggObj = FindPredefinedType(errorContext, PredefinedTypeFacts.GetName(PredefinedType.PT_OBJECT), KAID.kaidGlobal, AggKindEnum.Class, 0, true);
if (aggObj == null)
return false;
_aidMsCorLib = aggObj.GetAssemblyID();
}
_predefSyms = new AggregateSymbol[(int)PredefinedType.PT_COUNT];
Debug.Assert(_predefSyms != null);
return true;
}
示例9: NestedProgram
public NestedProgram(Program containingProgram)
{
IsNested = true;
ContainingProgram = containingProgram;
SymbolTable = new SymbolTable(containingProgram.SymbolTable);
SyntaxTree.Root.SymbolTable = SymbolTable;
}
示例10: Instantiate
public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
{
var parentEtl = ParentItem as AstEtlRootNode;
var transformationTemplate = Template as AstTransformationTemplateNode;
var clonedMapping = new Dictionary<IFrameworkItem, IFrameworkItem>();
if (transformationTemplate != null && parentEtl != null)
{
var clonedTransformations = new List<AstTransformationNode>();
foreach (var transformation in transformationTemplate.Transformations)
{
clonedTransformations.Add((AstTransformationNode)transformation.Clone(parentEtl, clonedMapping));
}
parentEtl.Transformations.Replace(this, clonedTransformations);
}
foreach (var bindingItem in transformationTemplate.UnboundReferences)
{
var clonedBindingItem = new BindingItem(
bindingItem.BoundProperty,
bindingItem.XObject,
bindingItem.XValue,
clonedMapping[bindingItem.ParentItem],
bindingItem.BimlFile,
this);
unboundReferences.Add(clonedBindingItem);
}
}
示例11: ParseProgramOrClass
public static void ParseProgramOrClass(TextSourceInfo textSourceInfo, ISearchableReadOnlyList<CodeElementsLine> codeElementsLines, TypeCobolOptions compilerOptions, SymbolTable customSymbols, out Program newProgram, out Class newClass, out IList<ParserDiagnostic> diagnostics)
{
// Create an Antlr compatible token source on top a the token iterator
CodeElementsLinesTokenSource tokenSource = new CodeElementsLinesTokenSource(
textSourceInfo.Name,
codeElementsLines);
// Init parser
ITokenStream tokenStream = new TokensLinesTokenStream(tokenSource, Token.CHANNEL_SourceTokens);
ProgramClassParser cobolParser = new ProgramClassParser(tokenStream);
// -> activate full ambiguities detection
//parser.Interpreter.PredictionMode = PredictionMode.LlExactAmbigDetection;
// Register all parse errors in a list in memory
DiagnosticSyntaxErrorListener errorListener = new DiagnosticSyntaxErrorListener();
cobolParser.RemoveErrorListeners();
cobolParser.AddErrorListener(errorListener);
// Try to parse a Cobol program or class
ProgramClassParser.CobolCompilationUnitContext codeElementParseTree = cobolParser.cobolCompilationUnit();
// Visit the parse tree to build a first class object representing a Cobol program or class
ParseTreeWalker walker = new ParseTreeWalker();
CobolNodeBuilder programClassBuilder = new CobolNodeBuilder();
programClassBuilder.CustomSymbols = customSymbols;
programClassBuilder.Dispatcher = new NodeDispatcher();
programClassBuilder.Dispatcher.CreateListeners();
walker.Walk(programClassBuilder, codeElementParseTree);
// Register compiler results
newProgram = programClassBuilder.Program;
newClass = programClassBuilder.Class;
diagnostics = errorListener.Diagnostics;
}
示例12: ProcessIsNullPatcherTransformations
public static void ProcessIsNullPatcherTransformations(SymbolTable symbolTable)
{
var snapshotSymbolTable = new List<IReferenceableItem>(symbolTable);
foreach (var astNamedNode in snapshotSymbolTable)
{
var nullPatcherNode = astNamedNode as AstIsNullPatcherNode;
if (nullPatcherNode != null && astNamedNode.FirstThisOrParent<ITemplate>() == null)
{
var astDerivedColumnListNode = new AstDerivedColumnListNode(nullPatcherNode.ParentItem)
{
Name = nullPatcherNode.Name,
ValidateExternalMetadata = nullPatcherNode.ValidateExternalMetadata
};
foreach (AstIsNullPatcherColumnNode patchColumn in nullPatcherNode.Columns)
{
var column = new AstDerivedColumnNode(astDerivedColumnListNode)
{
Name = patchColumn.Name,
ReplaceExisting = true,
Expression = String.Format(CultureInfo.InvariantCulture, "ISNULL({0}) ? {1} : {0}", patchColumn.Name, patchColumn.DefaultValue),
DerivedColumnType = VulcanEngine.IR.Ast.ColumnType.Object
};
astDerivedColumnListNode.Columns.Add(column);
}
Utility.Replace(nullPatcherNode, new List<AstTransformationNode> { astDerivedColumnListNode });
}
}
}
示例13: Execute
public override object Execute(SymbolTable table)
{
base.Execute(table);
StatementList.Execute(table);
return null;
}
示例14: CreateProgram
public void CreateProgram(string moduleName)
{
AssemblyName name = new AssemblyName(Path.GetFileNameWithoutExtension(moduleName));
var asmb = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save);
ModuleBuilder modb = asmb.DefineDynamicModule(moduleName);
var type = modb.DefineType("$program");
var symbolTable = new SymbolTable(type);
symbolTable.AddFunctionHeader("$main", MethodAttributes.Static, null, new FunctionDefinition.Argument[] { },"$program");
var il = symbolTable.functionTable["$main"].GetILGenerator();
Program.GenerateIL(il, symbolTable);
il.Emit(OpCodes.Ret);
modb.CreateGlobalFunctions();
asmb.SetEntryPoint(symbolTable.functionTable["$main"].methodDefinition);
symbolTable.typeTable.types[0].typeBuilder.CreateType();
asmb.Save(moduleName);
}
示例15: TypeCheckerVisitor
public TypeCheckerVisitor(ErrorHandler errors, StmtList statements)
{
Errors = errors;
SymbolTable = new SymbolTable();
Checker = new TypeChecker(errors);
RootStmtList = statements;
}