本文整理汇总了C#中PascalABCCompiler.SyntaxTree.ident类的典型用法代码示例。如果您正苦于以下问题:C# ident类的具体用法?C# ident怎么用?C# ident使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ident类属于PascalABCCompiler.SyntaxTree命名空间,在下文中一共展示了ident类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewUnitHeading
public unit_name NewUnitHeading(ident unitkeyword, ident uname, LexLocation loc)
{
var un = new unit_name(uname, UnitHeaderKeyword.Unit, loc);
if (unitkeyword.name.ToLower().Equals("library"))
un.HeaderKeyword = UnitHeaderKeyword.Library;
return un;
}
示例2: visit
public override void visit(for_node fn)
{
ProcessNode(fn.statements);
var b = HasStatementVisitor<yield_node>.Has(fn);
if (!b)
return;
var gt1 = goto_statement.New;
var gt2 = goto_statement.New;
var endtemp = new ident(newVarName());
var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value);
var if0 = new if_node(bin_expr.Greater(fn.loop_variable, fn.finish_value), gt1);
var lb2 = new labeled_statement(gt2.label, if0);
var lb1 = new labeled_statement(gt1.label);
var Inc = new procedure_call(new method_call(new ident("Inc"),new expression_list(fn.loop_variable)));
ReplaceStatement(fn, SeqStatements(ass1,ass2,lb2, fn.statements, Inc, gt2, lb1));
// в declarations ближайшего блока добавить описание labels
block bl = listNodes.FindLast(x => x is block) as block;
bl.defs.Add(new label_definitions(gt1.label, gt2.label));
}
示例3: visit
public override void visit(ident value)
{
if (value == null)
return;
int pos = value.name.LastIndexOf('`');
if (pos != -1)
value.name = value.name.Remove(pos);
SymbolInfo si = context.find(value.name);
if (si == null)
return; //ничего не нашли => переменная совсем локальная, никуда добавлять не нужно
if ((si.sym_info is SemanticTree.ICommonParameterNode) //параметр или
|| (si.sym_info is SemanticTree.ILocalVariableNode) //локальная переменная
|| (si.sym_info is SemanticTree.ICommonClassFieldNode) //поле класса
|| (si.sym_info is SemanticTree.ILocalBlockVariableNode)//локальная блочная переменная
|| isLoopVariable) //счетчик цикла
{
if (!Variables.Contains(si.sym_info as SemanticTree.IVAriableDefinitionNode))
Variables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode);
}
else if ((si.sym_info is SemanticTree.ICommonFunctionConstantDefinitionNode)//константа из функции
||(si.sym_info is SemanticTree.IClassConstantDefinitionNode)) //константа из класса
{
if (!Constants.Contains(si.sym_info as SemanticTree.IConstantDefinitionNode))
Constants.Add(si.sym_info as SemanticTree.IConstantDefinitionNode);
}
}
示例4: ReplaceCapturedVariablesVisitor
public ReplaceCapturedVariablesVisitor(IEnumerable<string> locals,
IEnumerable<string> formalParams,
IEnumerable<string> classFields,
IEnumerable<string> classMethods,
IEnumerable<string> classProperties,
IEnumerable<string> unitGlobals,
IDictionary<string, string> localsMap,
IDictionary<string, string> formalParamsMap,
bool isInClassMethod, bool isStaticMethod, ident className)
{
CollectedLocals = new HashSet<string>(locals);
CollectedFormalParams = new HashSet<string>(formalParams);
CollectedClassFields = new HashSet<string>(classFields);
CollectedUnitGlobals = new HashSet<string>(unitGlobals);
CapturedLocalsMap = new Dictionary<string, string>(localsMap);
CapturedFormalParamsMap = new Dictionary<string, string>(formalParamsMap);
IsInClassMethod = isInClassMethod;
ClassName = className;
// Methods hack
CollectedClassFields.UnionWith(classMethods);
// Properties hack
CollectedClassFields.UnionWith(classProperties);
}
示例5: visit
public override void visit(ident id)
{
// Check dot node
var upper = UpperNode(1);
//if (upper is dot_node)
// return;
var idName = id.name;
var idSourceContext = id.source_context;
if (idName.ToLower() == "self")
{
var newSelf = new dot_node(new ident("self"), new ident(Consts.Self));
Replace(id, newSelf);
}
// Detect where is id from
if (CollectedLocals.Contains(idName))
{
Replace(id, new ident(CapturedLocalsMap[idName], idSourceContext));
}
else if (CollectedFormalParams.Contains(idName))
{
Replace(id, new ident(CapturedFormalParamsMap[idName], idSourceContext));
}
else if (IsInClassMethod)
{
// In class -> check fields
if (CollectedClassFields.Contains(idName))
{
// Good
// Name in class fields -> capture as class field
var capturedId = new dot_node(new dot_node(new ident("self"), new ident(Consts.Self)), id);
Replace(id, capturedId);
}
else
{
// Bad
// At syntax we don't know if the name is class field or not coz of e.g. base .NET classes
// HERE WE SHOULD REPLACE TO yield_unknown_reference -> so decision is passed to semantic
// Check for globals will be processed at semantic, too
}
}
else
{
// Not in class -> check globals
if (CollectedUnitGlobals.Contains(idName))
{
// Global -> just do nothing
}
else
{
// What about static classes - search at semantic
// HERE WE SHOULD REPLACE TO yield_unknown_reference -> so decision is passed to semantic
}
}
}
示例6: NewVarNames
private VarNames NewVarNames(ident name)
{
_varnum++;
return new VarNames()
{
VarName = "$" + name.name + _varnum,
VarEndName = "<>varLV" + _varnum
};
}
示例7: visit
public override void visit(ident id)
{
if (id.name != _oldName.name)
{
return;
}
var upperNode = UpperNode();
if (
(object)upperNode != null && (object)(upperNode as dot_node) == null)
{
Replace(id, _newName);
}
}
示例8: visit
public override void visit(ident id)
{
int? paramNameLevel = null;
var paramName = id.name;
// Ищем с какого уровня имя
for (int level = formalParametersStack.Count - 1; level >= 0; --level)
{
if (formalParametersStack[level].ContainsKey(paramName))
{
// Нашли!
paramNameLevel = level;
break;
}
}
bool isField = false;
// Локальные параметры обрабатываются в другом визиторе
// Параметр функции
if ((object)paramNameLevel != null)
{
var upper = UpperNode();
// Подозреваем обращение к параметру метода
if ((object)upper == null || (object)upper != null && (upper as dot_node) == null)
{
// Это не self.paramName - поле класса и не что-то другое?
// Нашли обращение к параметру?
var self = new ident("self", id.source_context);
// Заменяем paramName -> self.hoistedParamName: <>num__paramName
var hoistedParamName = new ident(formalParametersStack[(int)paramNameLevel][paramName], id.source_context);
var selfId = new dot_node(self, hoistedParamName);
Replace(id, selfId);
}
// Иначе проверить что это поле класса! self.paramName или какой-то другой очень извращенный вариант вроде (someMethod: self).paramName
}
// Поле класса
// Параметр внешней функции (если наша - вложенная)
// Глобальная переменная
}
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:50,代码来源:ReplaceFormalParametersRefsVisitor.cs
示例9: NewQualifiedIdentifier
public method_name NewQualifiedIdentifier(method_name qualified_identifier, ident identifier, LexLocation loc)
{
var nqi = qualified_identifier;
nqi.class_name = nqi.meth_name;
nqi.meth_name = identifier;
nqi.source_context = loc;
return nqi;
}
示例10: visit
public override void visit(ident id)
{
if (indef)
ids.Add(id.name);
}
示例11: NewLambdaBody
public statement_list NewLambdaBody(expression expr_l1, LexLocation loc)
{
var _statement_list = new statement_list();
var id = new ident("result");
var _op_type_node = new op_type_node(Operators.Assignment);
//_op_type_node.source_context = parsertools.GetTokenSourceContext();
var _assign = new assign((addressed_value)id, expr_l1, _op_type_node.type);
parsertools.create_source_context(_assign, id, expr_l1);
_statement_list.subnodes.Add((statement)_assign);
_statement_list.source_context = loc;
//block _block = new block(null, _statement_list);
return _statement_list;
}
示例12: ReplaceForVariableVisitor
public ReplaceForVariableVisitor(ident oldName, ident newName)
{
_oldName = oldName;
_newName = newName;
}
示例13: NewFactor
public function_lambda_call NewFactor(ident func_decl_lambda, expression_list expr_list, LexLocation loc)
{
var fld = parsertools.find_pascalABC_lambda_name(func_decl_lambda.name);
var _expression_list = expr_list;
var _lambda_definition = fld;
var _lambda_call = new function_lambda_call(_lambda_definition, _expression_list, loc);
_lambda_call.source_context = func_decl_lambda.source_context;
return _lambda_call;
}
示例14: NewVarOrIdentifier
public var_def_statement NewVarOrIdentifier(ident identifier, named_type_reference fptype, LexLocation loc)
{
var n_t_r = fptype;
var vds = new var_def_statement();
vds.vars = new ident_list();
vds.vars.idents.Add(identifier);
vds.vars_type = n_t_r;
vds.source_context = loc;
return vds;
}
示例15: CheckVariableAlreadyDefined
private void CheckVariableAlreadyDefined(ident id)
{
string name = id.name;
if (IsVariableAlreadyDefined(name))
{
throw new PascalABCCompiler.Errors.SyntaxError(string.Format("Var {0} is already defined", name), "", id.source_context, id);
}
}
开发者ID:PascalABC-CompilerLaboratory,项目名称:pascalabcnet,代码行数:9,代码来源:CheckVariablesRedefenitionVisitor.cs