Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking on every NYI we hit while parsing a large code base #71

Merged
merged 11 commits into from
Dec 21, 2023
56 changes: 56 additions & 0 deletions src/lang/cpp/AST.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,59 @@ java rel[loc,loc] parseForMacros(loc file, str charset=DEFAULT_CHARSET, bool inf
@synopsis{All functions in this module that have a charset parameter use this as default.}
public str DEFAULT_CHARSET = "UTF-8";

public map[str, str] linusMacros = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, it's back :octocat:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange.. I must have git commit -amed again.. it's in my muscle memory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status now? are we ready to merge?

"_M_IX86": "600",
//"_WIN32": "1",
// "_MSC_VER": "1400"
"__cdecl": "",
"__fastcall": "",
"__restrict": "",
"__sptr": "",
"__stdcall": "",


"__unaligned": "",
"__uptr": "",
"__w64": "",
"__forceinline": "__inline",
"__int8": "char",
"__int16": "short",
"__int32": "int",
"__int64": "long long",

// additional:
//"_MSC_VER": "1700",
"__cplusplus": "199711L",
"__thiscall": "",
"_CHAR16T": "",
"_NATIVE_WCHAR_T_DEFINED": "1",
"__nullptr": "nullptr",
//"_MSC_EXTENSIONS": "1",
"__inline": "inline",
"__ptr32": "",
"__ptr64": "",
"__interface": "struct",

"__pragma(A)": "",
"__identifier(A)": "A",


// "__declspec(A)": "",
"_stdcall": "",

"_USE_DECLSPECS_FOR_SAL": "0",
//"_DLL": "1",

"NDEBUG": "",
//"WIN32": "",
//"_WINDOWS": "",
//"_WIN32_DCOM": "",
//"_USRDLL": "",
"SSCF1_INCLUDED": "",
"LOGGINGTRACING_INCLUDED": "",
//"_WINDLL": "",
"_UNICODE": "",
"UNICODE": ""
//"_AFXDLL": ""
// "__INTELLISENSE__": "1"
);
1 change: 1 addition & 0 deletions src/lang/cpp/TypeSymbol.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ data TypeSymbol
| \functionSetType(loc decl, list[TypeSymbol] templateArguments)
| \functionSetTypePointer(loc decl, list[TypeSymbol] templateArguments)

| \unaryTypeTransformation(str operator, TypeSymbol operand)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of encoding the operator as a string parameter. Can we specialize this per operator? Looking at the code, there's (currently) only one value in the operator enum anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that either. I'll have a look. If it's a small finite set we can have one transformation constructor per operator. Otherwise, we introduce an TypeTransformationOperator sort.

| \unresolved()
| \any()

Expand Down
55 changes: 38 additions & 17 deletions src/lang/cpp/internal/AST.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ public AST (IValueFactory vf) {
= tf.constructor(typestore,_TypeSymbol,"unspecified");
private static final Type _TypeSymbol_eUnionTemplate_2
= tf.constructor(typestore,_TypeSymbol,"eUnionTemplate",tf.sourceLocationType(),"decl",tf.listType(tf.sourceLocationType()),"templateParameters");
private static final Type _TypeSymbol_class_1
= tf.constructor(typestore,_TypeSymbol,"class",tf.sourceLocationType(),"decl");
private static final Type _TypeSymbol___nullType_0
= tf.constructor(typestore,_TypeSymbol,"__nullType");
private static final Type _TypeSymbol_eClassTemplate_2
Expand Down Expand Up @@ -746,6 +744,10 @@ public AST (IValueFactory vf) {
= tf.constructor(typestore,_TypeSymbol,"cUnionTemplate",tf.sourceLocationType(),"decl",tf.listType(tf.sourceLocationType()),"templateParameters");
private static final Type _TypeSymbol_functionSetType_2
= tf.constructor(typestore,_TypeSymbol,"functionSetType",tf.sourceLocationType(),"decl",tf.listType(_TypeSymbol),"templateArguments");
private static final Type _TypeSymbol_unaryTypeTransformation_2
= tf.constructor(typestore,_TypeSymbol,"unaryTypeTransformation",tf.stringType(),"operator",_TypeSymbol,"operand");
private static final Type _TypeSymbol_class_1
= tf.constructor(typestore,_TypeSymbol,"class",tf.sourceLocationType(),"decl");
private static final Type _TypeSymbol_typeOfDependentExpression_1
= tf.constructor(typestore,_TypeSymbol,"typeOfDependentExpression",tf.stringType(),"name");
private static final Type _TypeSymbol_implicitTemplateTypeParameter_2
Expand Down Expand Up @@ -6234,21 +6236,6 @@ public IConstructor TypeSymbol_eUnionTemplate(ISourceLocation $decl, IList $temp
return vf.constructor(_TypeSymbol_eUnionTemplate_2 , $decl, $templateParameters).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_class(ISourceLocation $decl) {

if (!$decl.getType().isSubtypeOf(tf.sourceLocationType())) {
throw new IllegalArgumentException("Expected " + tf.sourceLocationType() + " but got " + $decl.getType() + " for $decl:" + $decl);
}

Map<String, IValue> kwParams = new HashMap<String, IValue>();





return vf.constructor(_TypeSymbol_class_1 , $decl).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol___nullType() {

Map<String, IValue> kwParams = new HashMap<String, IValue>();
Expand Down Expand Up @@ -6771,6 +6758,40 @@ public IConstructor TypeSymbol_functionSetType(ISourceLocation $decl, IList $tem
return vf.constructor(_TypeSymbol_functionSetType_2 , $decl, $templateArguments).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_unaryTypeTransformation(String $operator, IConstructor $operand) {

if (!vf.string($operator).getType().isSubtypeOf(tf.stringType())) {
throw new IllegalArgumentException("Expected " + tf.stringType() + " but got " + vf.string($operator).getType() + " for vf.string($operator):" + vf.string($operator));
}

if (!$operand.getType().isSubtypeOf(_TypeSymbol)) {
throw new IllegalArgumentException("Expected " + _TypeSymbol + " but got " + $operand.getType() + " for $operand:" + $operand);
}

Map<String, IValue> kwParams = new HashMap<String, IValue>();





return vf.constructor(_TypeSymbol_unaryTypeTransformation_2 , vf.string($operator), $operand).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_class(ISourceLocation $decl) {

if (!$decl.getType().isSubtypeOf(tf.sourceLocationType())) {
throw new IllegalArgumentException("Expected " + tf.sourceLocationType() + " but got " + $decl.getType() + " for $decl:" + $decl);
}

Map<String, IValue> kwParams = new HashMap<String, IValue>();





return vf.constructor(_TypeSymbol_class_1 , $decl).asWithKeywordParameters().setParameters(kwParams);
}

public IConstructor TypeSymbol_typeOfDependentExpression(String $name) {

if (!vf.string($name).getType().isSubtypeOf(tf.stringType())) {
Expand Down
10 changes: 6 additions & 4 deletions src/lang/cpp/internal/TypeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNaryTypeIdExpression.Operator;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.c.CStructure;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTemplateTypeParameter;
Expand Down Expand Up @@ -600,10 +601,11 @@ private IConstructor resolveICPPEnumerationSpecialization(ICPPEnumerationSpecial
return builder.TypeSymbol_enumerationSpecialization(specializedBinding, templateArguments);
}

private IConstructor resolveICPPUnaryTypeTransformation(ICPPUnaryTypeTransformation type, ISourceLocation origin) {
// Operator operator = type.getOperator();
// IType operand = type.getOperand();
throw new RuntimeException("NYI: resolveICPPUnaryTypeTransformation @ " + origin);
private IConstructor resolveICPPUnaryTypeTransformation(ICPPUnaryTypeTransformation type, ISourceLocation origin) {
String op = type.getOperator().name();
IConstructor operand = resolveType(type.getOperand(), origin);

return builder.TypeSymbol_unaryTypeTransformation(op, operand);
}

private IConstructor resolveICPPUnknownType(ICPPUnknownType type, ISourceLocation origin) {
Expand Down
Loading